Strange javascript error in parseInt Hello

Axel Richter




the function parseInt(string, radix) has a second parameter radix, see

If there is a leading zero in the string, the radix defaults to octal (8). In octal system there are only numerics from 0 to 7. So "08" is 0, "09" is 0 and "010" is 8 ;-).

Set the radix parameter to 10 if you like to have decimal numbers.

alert(parseInt(num, 10));



0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact