Easy Tutorial
❮ Jsref Eval Jsref Sup ❯

JavaScript isNaN() Function

JavaScript Global Functions


Definition and Usage

The isNaN() function is used to determine whether a value is an illegal number.

It returns true if the value is NaN or a string, object, undefined, etc., that is not a number; otherwise, it returns false.

Syntax

Parameter Description
value Required. The value to be tested.

Browser Support

All major browsers support the isNaN() function.


Example

Check if a number is illegal:

document.write(isNaN(123) + "<br>");
document.write(isNaN(-1.23) + "<br>");
document.write(isNaN(5-2) + "<br>");
document.write(isNaN(0) + "<br>");
document.write(isNaN("Hello") + "<br>");
document.write(isNaN("2005/12/12") + "<br>");

The above example outputs:


JavaScript Global Functions

❮ Jsref Eval Jsref Sup ❯