As the other answers say, leading zeros make a number an octal literal. The decimal representation of the octal "15" is "13".
Note that there is no reason to use leading zeros in numeric literals unless you really want to be interpreted as octal. I mean, do not use var b = 00015 . If you get this value from user input, then it will be a string (ie "00015" ), and you can convert it to decimal using parseInt :
var b = "00015"; // or var b = document.getElementById('some_input').value var numB = parseInt(b, 10); // 15
source share