I guess I can format it back. I'm just interested in why it's happening.
function test(d){
 console.log(d) // 151028224
}
console.log(test(00001100101000))
I guess I can format it back. I'm just interested in why it's happening.
function test(d){
 console.log(d) // 151028224
}
console.log(test(00001100101000))
The function has nothing to do with it.
The JavaScript compiler converts your number literal into a Number when it compiles the source code.
Since the number starts with a 0, it is treated as octal instead of decimal.
 
    
     
    
    By default, any number literally written with a zero at the beginning is considered as octal (base 8) number representation, and then, when you show back any number with console.log, it is written as its base 10 representation.
console.log(05)
console.log(06)
console.log(07)
console.log(010)
console.log(011)It's recommended to avoid this in code, because it can lead to confusions :
if the number contains the digits 8 or 9, it cannot be a base-8 number, and thus treated as base 10 !
console.log(05)
console.log(06)
console.log(07)
console.log(08) // Yiiik !
console.log(09) // Yiiik !
console.log(010)
console.log(011)