JavaScript isNaN() Function
JavaScript Functions
Definition and Usage
The isNaN() function is used to check if a value is not a legal number, NaN
(Not-a-Number).
Syntax
| Parameter |
Description |
| value |
Required. The value to be tested |
Example
Example
Check for NaN values:
<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>
|
The output of the code above will be:
false
false
false
false
true
true
|
Try it yourself »
|
JavaScript Functions
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 4000 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
|