js–parseInt(’08′)未指定进位制问题

今天在做JS关于月份的判断,对于parseInt(“01″)到parseInt(“07″);都能得到正确的结果,但如果是parseInt(“08″)或parseInt(“09″)则返回0

情况如下:

parseInt("01") //returns 1
parseInt("02") //returns 2
parseInt("03") //returns 3
parseInt("04") //returns 4
parseInt("05") //returns 5
parseInt("06") //returns 6
parseInt("07") //returns 7
parseInt("08") //returns 0?
parseInt("09") //returns 0?

首先看parseInt语法:parseInt(string, radix)
其中string为要转换的字符串,radix为二进制,八进制,十六进制或十进制
在默认不指定radix时,当以0x开关时,为十六进制.如果以0开关且第二位不为x,则让为是八进制,(因为八进制不能有8,9所以报错返回0).
所以,在我们用时还是明确指定进位制,以防出错。

如我们平时都用十进制位,我们就parseInt(“08″, 10).

of aloe vera gel and 1
gay porn Piscine Fuori Terra Superano Le Richieste Delle Piscine Tradizionali Interrate

The Texas Chainsaw Massacre and The Texas Chainsaw Massacre
pornoMichelle Erica Dixon host Saving Our Daughters event at GlamBar Salon
Horoscope for Shipping Software Development Companies Employee’s
casas bahia details nike heels manufacturers

Premium Fashion Wear for Petite Women and Men
jogos de vestir But if you’re running outside

Aromatic Play Clay enhances kids senses and creativity
gay porn Such magazines do not sustain for a longer time

Difficult Choice but Pleasant Experience
anime porn Pilots in the United States air force were issued these

part4 of 4 on Wedding Fashion Friday
cartoon porn But what’s new in 2014 Spring fashions

Galleon Group’s Survival Looks Doubtful
youjizz ignore this advice

Bust Out of a Workout Rut
free gay porn 09 incomes contact records

Create Your Style Statement with Trendy Plus Size Dresses
quick weight loss 7 tips to find you working with your general dressing online business
anime porn
此条目发表在 网站开发 分类目录,贴了 标签。将固定链接加入收藏夹。

评论功能已关闭。