why parseInt('08') is giving 0, whereas parseInt('07') is giving 7 [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-04 01:11:34

Yeah, I came across this one before. It is really odd because some browsers interpret this as you wanting to parse it in base 8. Consider the following article:

http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256C85006A6604

basically, you have to tell the parser to use base 10 numbers:

parseInt('08', '10');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!