Blogger Information
Blog 2
fans 0
comment 0
visits 2273
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
javascript的parseInt的用法
雨星辰~的博客
Original
844 people have browsed it

上次再用parseInt转一个有前导的数字,012时,总是转成10.当时还不知道原因,现在知道了,

例如:

var str = "012";
var b = parseInt(str);
alert(b)

总是弹出b为10.原因是在有前导0的时候。如果后面跟数字,则转为8进制了,如果后面跟字母,就转为16进制了。所以要想转为我们说说  的数字,就是10进制,必须这样.

 

b = parseInt(str,10)

这样,就会弹出12了.

后面加个数字在2-36之间,表示进制.此处转为了10进制.


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post