We can define integer literal in decimal, hexadecimal, octal or binary.
Version
ECMAScript 2015
Decimal Integer
let x = 100 // ?
A decimal integer literal is a sequence of digits without a leading 0
.
Octal Integer
let x = 0100 // ?
let y = 0o100 // ?
A octal integer literal is a sequence of digits with a leading 0
or a leading 0o
.
Hexadecimal Integer
let x = 0xffff // ?
A decimal integer literal is a sequence of digits with a leading 0x
.
Binary Integer
let x = 0b0010 // ?
A binary integer literal is a sequence of digits with a leading 0b
.
Conclusion
- Be careful about leading
0
. It is an octal integer, not a decimal integer