# Number isNaN() Method - Javascript Number

Javascript examples for Number:isNaN

## Description

The Number.isNaN() returns true if the value is of the type Number, and equates to NaN. Otherwise it returns false.

The global isNaN() function converts the tested value to a Number, then tests it.

Number.isNaN() does not convert the values to a Number, and returns false if it is not a Number.

## Parameter Values

Parameter Description
value Required. The value to be tested

## Return Value:

A Boolean. Returns true if the value is Number.NaN, otherwise it returns false

The following code shows how to Check whether a value is NaN:

## Demo Code

```<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from  ww w .j a v a 2s .c  o m*/
var res = "";
res = res + Number.isNaN(123) + ": 123<br>";
res = res + Number.isNaN(-1.23) + ": -1.23<br>";
res = res + Number.isNaN(5-2) + ": 5-2<br>";
res = res + Number.isNaN(0) + ": 0<br>";
res = res + Number.isNaN('123') + ": '123'<br>";
res = res + Number.isNaN('Hello') + ": 'Hello'<br>";
res = res + Number.isNaN('2020/12/12') + ": '2020/12/12'<br>";
res = res + Number.isNaN('') + ": ''<br>";
res = res + Number.isNaN(true) + ": true<br>";
res = res + Number.isNaN(undefined) + ": undefined<br>";
res = res + Number.isNaN('NaN') + ": 'NaN'<br>";
res = res + Number.isNaN(NaN) + ": NaN<br>";
res = res + Number.isNaN(0 / 0) + ": 0 / 0<br>";

document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>
```