1

Write out 074 in the console and it'll return 60.

074
>>60

Why?

A F
  • 7,424
  • 8
  • 40
  • 52

1 Answers1

5

Adding a zero before a number tells javascript to interpret it as an octal (base 8) value.

According to the MDN documentation on number literals, you can use the following to represent numbers on different base:

  • decimal: numbers starting with any digit other than zero are decimal.
  • binary: numbers starting with 0b or 0B
  • octal: numbers starting with 0
  • hexadecimal starting with 0x or 0X`
  • exponentiation ending with e followed by a number (1e3 = 1x103)
lucascaro
  • 16,550
  • 4
  • 37
  • 47