I pass the identifier of the javascript function as a parameter, because it comes from the user interface, it is padded with zeros. but it seems to have (maybe) "weird" behavior?
console.log(0000020948); //20948 console.log(0000022115); //9293 which is 22115 octal console.log(parseInt(0000022115, 10)); // 9293 which is 22115 octal console.log(0000033959); //33959 console.log(20948); //20948 console.log(22115); //22115 console.log(33959); //33959
How can I make sure they are parsed into the correct numbers? (decimal)
EDIT:
just make it clearer:
these numbers come from the server and are strings padded with zeros. and I make a delete button for each.
like:
function printDelButton(value){ console.log(typeof value); //output string return '<a href="#" onclick="deleteme('+value+')"><img src="images/del.png"></a>' } and function printDelButton(value){ console.log(typeof value); //output numeric console.log(value); //here output as octal .... :S }
I did my best:
console.log(parseInt(0000022115, 10));
and still understand how octal
source share