[thelist] JavaScript : How to determine if float or integer

Danny Goodman dannyg at dannyg.com
Tue Jan 28 10:28:16 CST 2003


Test for the equality of parseInt() and parseFloat() on the value. If
parseInt(n) == parseFloat(n), then the number is an integer; otherwise it's
a floater, as far as JavaScript is concerned (where the number 3.0000
automatically evaluates to the integer 3).

Danny
http://www.dannyg.com

> I have a simple script to write, in this Script I want to figure out if
> a variable returned is either a float or integer, with "typeof" both are
> returned as "number".
>
> Do you know any other way than scanning for the point in the whole
> variable?




More information about the thelist mailing list