alert(010),结果是8,为什么? 我阅读了 ecmascript 7.8.3 Numeric Literals。 根据 Numeric Literals Lexical, 010 是无效的数字文字。
最佳答案
只有开启严格模式才会这样:
(function(){
"use strict";
010;
})();
SyntaxError: Octal literals are not allowed in strict mode.
否则会破坏向后兼容性。
关于javascript - 关于数字文字词法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10283856/