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...?
var n = '08'; var r = parseInt(n); // r is zero not 8
தீர்வு தேர்ந்தெடுக்கப்பட்டது
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)
தீர்வு தேர்ந்தெடுக்கப்பட்டது
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);
cor-el மூலமாக
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...
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.
thank's...
You're welcome.