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.
<scripttype="text/javascript">var num=0/0;document.write("Output : " + num.isNaN());</script>chevron_rightfilter_noneOutput:
Output : true
- When a number is passed as a parameter.
<scripttype="text/javascript">var num=213;document.write("Output : " + num.isNaN());</script>chevron_rightfilter_noneOutput:
Output : false
- When a number in string representation is passed as a parameter.
<scripttype="text/javascript">var test='213';document.write("Output : " + test.isNaN());</script>chevron_rightfilter_noneOutput:
Output : false
- When a string is passed as a parameter.
<scripttype="text/javascript">var test='hello';document.write("Output : " + test.isNaN());</script>chevron_rightfilter_noneOutput:
Output : false
- When Nan is passed as a parameter.
<scripttype="text/javascript">var check=Nan;document.write("Output : " + check.isNaN());</script>chevron_rightfilter_noneOutput:
Output : true
Recommended Posts:
- this in JavaScript
- Map in JavaScript
- Map.get( ) In JavaScript
- Map.has( ) In JavaScript
- Debouncing in JavaScript
- JavaScript | Callbacks
- Object.is( ) in JavaScript
- JavaScript JSON
- JavaScript | Array pop()
- Math.tan( ) In JavaScript
- Math.cos( ) In JavaScript
- Math.log( ) In JavaScript
- JavaScript | typedArray.set() with Example
- JavaScript | typedArray.some() with Example
- JavaScript | Generator
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



