/

HTML / CSS / JavaScript Tutorial

JavaScript Global property: NaN

[this page | pdf | back links]

The JavaScript Global NaN property returns NaN (i.e. ‘not a number’).

 

It has the following syntax:

 

NaN

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td,tr,th,caption {border: thin solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table >
  <tr><th>Global property</th><th>Value returned</th></tr>
  <tr><td>'infinity'</td><td id="x1"></td></tr>
  <tr><td>'not a number'</td><td id="x2"></td></tr>
  <tr><td>'not defined'</td><td id="x3"></td></tr>
</table>

<script id="element">
document.getElementById("x1").innerHTML = Infinity;
document.getElementById("x2").innerHTML = NaN;
document.getElementById("x3").innerHTML = undefined;
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile