Skip to content Skip to sidebar Skip to footer

Javascript Returns 9 For 0011

I have a function where I passes the value dynamically 0011 In javascript am just passing this value and

Solution 1:

0011 is an octal number since it has a leftmost 0 so its equal to 0 x 8 + 1 x 8 + 1 x 8 = 9. Originally the value was interpreted as a numeric. Enclosing it in quotes caused it to be treated as a String literal.


Post a Comment for "Javascript Returns 9 For 0011"