Join the Mozilla’s Test Days event from 9–15 Jan to test the new Firefox address bar on Firefox Beta 135 and get a chance to win Mozilla swag vouchers! 🎁

This site will have limited functionality while we undergo maintenance to improve your experience. If an article doesn't solve your issue and you want to ask a question, we have our support community waiting to help you at @FirefoxSupport on Twitter and/r/firefox on Reddit.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

can u help me? why if i use parseInt javascript function for special character number '08' and '09' return is zero for all version firefox...?

  • 5 replies
  • 2 have this problem
  • 1 view
  • Last reply by cor-el

more options

var n = '08'; var r = parseInt(n); // r is zero not 8

var n = '08'; var r = parseInt(n); // r is zero not 8

Chosen solution

You need to specify the number base (10).
If not then Firefox might think that it is an octal number and in that case 8 and 9 are invalid.

var n = '08'; var r = parseInt(n,10); // r is 8 
alert(r);
Read this answer in context 👍 0

All Replies (5)

more options

Chosen Solution

You need to specify the number base (10).
If not then Firefox might think that it is an octal number and in that case 8 and 9 are invalid.

var n = '08'; var r = parseInt(n,10); // r is 8 
alert(r);

Modified by cor-el

more options

thanks for the reply...

can u set default base number in firefox is 10, because other web browser if i parseInt('08') result in 8 n many beginner web developer think parseInt('08') is 8... just a suggestion...

thx again...

more options

No, that is not possible.
The result of parsing an integer with leading zeros can be unpredictable and it is always best to specify the number base anyway to make clear what you mean.

more options

thank's...

more options

You're welcome.