Search code examples
javascriptleading-zero

Javascript variable with leading zeroes


Javascript behaves differently with values having leading zeroes. alert(b) - prints different value.

var a = 67116;
var b = 00015;
alert(a);
alert(b);

I am more interested to know What conversion is applied here by javascript inside alert(b) ? (If i have them in double quotes. They work fine.)


Solution

  • var b = 00015
    

    is an octal number

    see this question for solution