Friday, April 10, 2015

JavaScript isNaN() Function

Check whether a number is an illegal number:

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

var res = a + b + c + d + e + f;

false
false
false
false
true
true

No comments:

Post a Comment