javascript - What happens when a number has a leading zero? -
i've been trying debug problem today , found out problem is. reason, when number has leading 0 javascript weird.
example:
alert(132); alert(0132); var test = 0132; alert(test);
jsfiddle: http://jsfiddle.net/u8sfu/3/
the first popup says "132," second "90," , third says "90."
my question is, why number 0132 become number 90? baffling me!
a number leading 0 parsed octal literal, in base 8.
Comments
Post a Comment