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
  • 8,583
  • 2
  • 25
  • 27
0

0 starts an octal literal, not a decimal.

Esailija
  • 138,174
  • 23
  • 272
  • 326