0

I realized this while using the Chrome Devtools.

100 + 2 // outputs 102
0100 + 2 // outputs 66
01001 + 6 // outputs 519
060 + 3 // outputs 51
024 + 9 // outputs 29

Anyone can explain what is going on?

2 Answers2

1

The leading zero indicates that the number literal is in octal, that is, base 8.

MatthewG
  • 7,404
  • 2
  • 24
  • 27
0

0 starts an octal literal, not a decimal.

Esailija
  • 134,577
  • 23
  • 263
  • 318