It depend of the version of EcmaScript and the browser.
"If the input string begins with "0", radix is eight (octal). This feature is non-standard, and some implementations deliberately do not support it (instead using the radix 10)."
"The ECMAScript 5 specification of the function parseInt no longer allows implementations to treat Strings beginning with a 0 character as octal values."
Comment
The simplest form of isInt is as follows (for a number n):
parseInt(n) === n; //isInt
That's it - you don't need a function call! Similarly, we have the following:
parseInt(n) !== n; //isNotInt
parseFloat(n) === n; //isFloat
parseFloat(n) !== n; //isNotFloat
Replies
And how would you check this "03" ?
It depend of the version of EcmaScript and the browser.
"If the input string begins with "0", radix is eight (octal). This feature is non-standard, and some implementations deliberately do not support it (instead using the radix 10)."
"The ECMAScript 5 specification of the function parseInt no longer allows implementations to treat Strings beginning with a 0 character as octal values."
(Source : https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt )
So... For this reason, you should always specify a radix when using parseInt().
parseInt("03", 10);
Why this:
var n = 3.0;
alert(parseInt(n)===n);
alerts "true"?
Python does the same:
>>> 3.0 == 3
True
But in python you can do:
>>> 3 is 3
True
>>> 3.0 is 3.0
True
>>> 3.0 is 3
False