Below is the example of the Number.isNaN() Method.
- Example:
<script>function GFGFun() {var res = "";res = res + Number.isNaN(123);document.write(res);}GFGFun();</script>chevron_rightfilter_none - 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
- 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();</script>chevron_rightfilter_noneOutput:
Output : true
- When a number is passed as a parameter.
<script>function GFGFun() {var res = "";res = res + Number.isNaN(321);document.write(res);}GFGFun();</script>chevron_rightfilter_noneOutput:
Output : false
- 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();</script>chevron_rightfilter_noneOutput:
Output : false
- When a string is passed as a parameter.
<script>function GFGFun() {var res = "";res = res + Number.isNaN("hello");document.write(res);}GFGFun();</script>chevron_rightfilter_noneOutput:
Output : false
- When Nan is passed as a parameter.
<script>function GFGFun() {var res = "";res = res + Number.isNaN(NaN);document.write(res);}GFGFun();</script>chevron_rightfilter_noneOutput:
Output : true
Supported Browsers:
- Google Chrome
- Internet Explorer 12
- Firefox 32
- Apple Safari 9
- Opera 22


