这个答案已经晚了,但我这边仍然有更新。正如 Pointy 在严格模式下所说的,八进制常量是不允许的。
'use strict'
if(022 == 22){
console.log("True");
}
console.log("Failed")
抛出异常
{
"message": "Uncaught SyntaxError: Octal literals are not allowed in strict mode.",
"filename": "https://stacksnippets.net/js",
"lineno": 14,
"colno": 4
}
即使我们将第二个数字添加为8
或9
仍然0
不允许在strict mode
'use strict'
if(029 == 29){
console.log("True");
}
console.log("Failed")
它也会抛出异常
{
"message": "Uncaught SyntaxError: Decimals with leading zeros are not allowed in strict mode.",
"filename": "https://stacksnippets.net/js",
"lineno": 14,
"colno": 4
}
而且它没有任何意义,因为前导零是没有前导零的相同值。但是在接收来自另一方的值时需要小心。