console.log(01)
results in 1
But
console.log(011)
results in 9
Can someone explain how console.log
works with such numbers?
console.log(01)
results in 1
But
console.log(011)
results in 9
Can someone explain how console.log
works with such numbers?
It's not about console.log, a number that starts with 0 is octal notation
console.log(+"011") // if you use like this it will work
011
is an octal value and its decimal equivalent is 9. Preceding integer literal with 0 indicates octal value.