JavaScript isNaN() Function

JavaScript isNaN() Function

The isNaN() function determines whether a value is an illegal number (Not-a-Number).

This function returns true if the value is NaN, and false if not.

Syntax

isNaN(value)

Example

<script type="text/javascript">

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

</script>

Output

false
false
false
false
true
true
DOWNLOAD SOLUTION HERE