Comment

Anonymous

And how would you check this "03" ?

Parent comment

Aadit M Shah

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

Bobinours

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);