Thursday, June 19, 2014

check for nan javascript

The isNaN() function returns true if the value is NaN (Not-a-Number), and false if not.

var a = isNaN(123) + "<br>";
var b = isNaN(-1.23) + "<br>";
var c = isNaN(5-2) + "<br>";
var d = isNaN(0) + "<br>";
var e = isNaN("Hello") + "<br>";
var f = isNaN("2005/12/12") + "<br>";

false
false
false
false
true
true

No comments:

Post a Comment