0

I have a question about how javascript parses integers beginning with zero(for example a bank account number). Simple example below from chrome dev tools.

var zeroTest = 022;
//undefined

zeroTest
// 18

why does this become 18? Is there a robust interpretation that can be used for any input beginning with zero to find the resulting value when var is accessed?

Rajesh
  • 24,354
  • 5
  • 48
  • 79

1 Answers1

2

Leading zero in literal indicates that you want to use an octal (base 8) number.

Samuil Petrov
  • 542
  • 1
  • 13
  • 24
  • Just a pointer, you should not answer a duplicate. If you read a question which is very basic, there is a high possibility that it has been answered before and you should search for such posts and share its link in comment. This way someone can close question – Rajesh Mar 02 '17 at 10:04