A doubt about the number 0 in javascript

Asked

Viewed 33 times

2

I wanted to understand something, because when I put the number 0 ahead at the time of printing on console the number comes out totally different, but when I don’t put the number 0 at the beginning the number appears normal?

 var numero = 066233;
 var numero2 = 66233;
 console.log(numero,numero2)

  • 1

    Just out of curiosity, if you do var numero = 068233; is no longer an octal because the digit 8 causes the lexicographer to interpret the number as decimal.

1 answer

1


Numbers started at 0 are interpreted as Octal.

Non-zero Start = Decimal (base 10, "normal numbers")

Start 0 = Octal (base 8)

Start 0x = Hexadecimal (base 16)

  • It is Octal same, I already edited in the reply. I used the wrong name in en...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.