i wrote from 001 to 0010 and much more digit like this that started with "00" in chrome console and Fire Fox even in IE and get this result.
why 0010 is not equal to 10 ? or why 0020 is not equal to 20 ? and it is "16".
i wrote from 001 to 0010 and much more digit like this that started with "00" in chrome console and Fire Fox even in IE and get this result.
why 0010 is not equal to 10 ? or why 0020 is not equal to 20 ? and it is "16".
“如果数字常量前面有零,则将其视为八进制,如果前面有零和 x (0x),则将其视为十六进制。” (如此处所述)
008 不被视为八进制,因为它包含不是八进制数的“8”。0010 实际上是一个八进制数,等于 8。
Javascript 中的数字文字可以以不同的基数输入 -
前导零表示该数字是八进制基数(仅数字 0-7),因此 010 等于:一次 8 + 零
文字 0x10 是十六进制(以 16 为底),因此等于:一乘以 16 + 零)= 16
见这里https://developer.mozilla.org/en/docs/JavaScript/Guide/Values,_variables,_and_literals