# JavaScript Number.isNaN() Method

• Last Updated : 24 Dec, 2021

Below is the example of the Number.isNaN() Method.

• Example:

 `<``script``> ` `function GFGFun() { ` `  ``var res = ""; ` `  ``res = res + Number.isNaN(123); ` `document.write(res);   ` ` `  `} ` `GFGFun(); ` ` `

• Output:
`false`

The Number.isNan method in JavaScript is used to determines whether the passed value is NaN(Not a Number) and is of the type “Number”.
In JavaScript, the value NaN is considered a type of number.

Syntax:

`Number.isNaN(value)`

Parameters Used:
1. Value :It is the value which is to be tested for NaN.

Return Value:
The Number.isNaN() method in JavaScript returns true if the passed value is Nan and is of the type number,else it returns false.

Examples:

```Input : 0/0
Output : true

Input : 213
Output : false

Input : '213'
Output : false

Input : 'hello'
Output : false

Input : NaN
Output : true

```
1. When an equation resulting in infinite value is passed as a parameter.

 `<``script``> ` `function GFGFun() { ` `  ``var res = ""; ` `  ``res = res + Number.isNaN(0/0); ` `document.write(res);   ` ` `  `} ` `GFGFun(); ` ` `

Output:

`Output : true`
2. When a number is passed as a parameter.

 `<``script``> ` `function GFGFun() { ` `  ``var res = ""; ` `  ``res = res + Number.isNaN(321); ` `document.write(res);   ` ` `  `} ` `GFGFun(); ` ` `

Output:

`Output : false`
3. When a number in string representation is passed as a parameter.

 `<``script``> ` `function GFGFun() { ` `  ``var res = ""; ` `  ``res = res + Number.isNaN(213); ` `document.write(res);   ` ` `  `} ` `GFGFun(); ` ` `

Output:

`Output : false`
4. When a string is passed as a parameter.

 `<``script``> ` `function GFGFun() { ` `  ``var res = ""; ` `  ``res = res + Number.isNaN("hello"); ` `document.write(res);   ` ` `  `} ` `GFGFun(); ` ` `

Output:

`Output : false`
5. When Nan is passed as a parameter.

 `<``script``> ` `function GFGFun() { ` `  ``var res = ""; ` `  ``res = res + Number.isNaN(NaN); ` `document.write(res);   ` ` `  `} ` `GFGFun(); ` ` `

Output:

`Output : true`

Supported Browsers:

• Google Chrome 25 and above
• Firefox 15 and above
• Apple Safari 9 and above
• Opera 15 and above
• safari 9 and above

My Personal Notes arrow_drop_up
Recommended Articles
Page :