Possible Duplicate:
Workarounds for JavaScript parseInt octal bug
Parsing a string using parseInt method returns invalid output .
Code :
parseInt("08");
Excepted Output :
8
Real Output :
0
Code [This returns output correctly] :
parseInt("8")
Output :
8
Why it happens ?
You need to specify the base:
Otherwise JavaScript doesn’t know if you are in decimal, hexadecimal or binary.
(This is a best practise you should always use if you use parseInt.)