Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一段 javaScript 代码:
var val = parseInt("08"); alert("Val : " + val);
它显示 val 为 0。
iOS 中的同一段代码显示 8。
有人可以更清楚地说明这个问题吗?
谢谢。
这是因为您使用 parseInt 时没有定义要使用的基数。现在它认为您使用 8 作为基数。
试试这个:
var val = parseInt('08', 10);