This question has already been answered:

When writing numbers with extra zeros, the result is unexpected:

let i = 000042; console.log(i); // 34 

and different numbers are reduced by different values. How can this be corrected?

Reported as a duplicate at Grundy. javascript May 3, 18 at 14:37 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • 2
    1) Do not write numbers with leading zeros. 2) If you really really want, then let i = parseInt('000042', 10); - Yaant

1 answer 1

https://developer.mozilla.org/bm/docs/Web/JavaScript/Guide/Grammar_and_types

Leading 0 (zero) on an integer literal, or leading 0o (or 0O) indicates it is in octal. Octal integers can only include the digits 0-7.

I.e

A zero (either 0o or 0O) at the beginning of the number entry indicates that the number is written in octal.

Where do the numbers in such a record come from in your javascript?

  • In my javascript-e there are no such numbers. In general, the question I pulled out of the context of the problem with the codewars - Andrew