Because 01000
, 512
, 0o535
, and 349
are all numbers. 01000
and 512
are the same value written different ways (a "legacy" octal literal and a decimal literal); so are 0o535
and 349
(a new-style octal literal and a decimal literal). The form of literal you use makes no difference to the value or type of what it creates. Similarly, 'foo' === "foo"
is true, even though I use the single-quoted string literal in one and the double-quoted string literal in the other.
About the two kinds of octal literals:
01000
is a "legacy" octal literal, indicated by just the leading zero. JavaScript engines in web browsers are required (as of ES2015) to support them in loose mode, and to not support them in strict mode (e.g., "use strict")
. (Note that loose mode and strict mode have nothing to do with loose equality and strict equality, which is a separate concept.) So in a compliant, browser-based JavaScript engine, 01000 === 512
is true in loose mode, but an error in strict mode, because legacy octal literals are not allowed in strict mode. (Prior to ES2015, supporting legacy octal literals in loose mode was not required.)
0o535
is the newer octal notation added in ES2015, indicated with the leading 0o
. It's supported in both loose and strict modes by compliant JavaScript engines. But again, it's new, so older browsers won't be compliant.