Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does JavaScript convert parseInt(0000000101126) to 33366 instead of 101126? [duplicate]

Tags:

javascript

Why does JavaScript convert parseInt(0000000101126) to 33366 instead of 101126?

var example = parseInt(0000000101126);
console.log(example); //33366 
like image 944
Jonathan Avatar asked Oct 20 '22 16:10

Jonathan


1 Answers

JavaScript assumes the following:

•If the string begins with "0x", the radix is 16 (hexadecimal)
•If the string begins with "0", the radix is 8 (octal). This feature is deprecated
•If the string begins with any other value, the radix is 10 (decimal)

like image 170
Zzyrk Avatar answered Nov 15 '22 00:11

Zzyrk