1

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

074 >>60 

Why?

2
  • 5
    Numbers with a leading zero are octal, just like numbers with leading 0x are hex. Commented Nov 15, 2018 at 20:04
  • I agree with @Niet the Dark Absol... if you want to get 074 write into console "074" like a string... Commented Nov 15, 2018 at 20:08

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.