JavaScript Number.isNaN() Method
You are Here:
JavaScript Number.isNaN() Method
The Number.isNaN()
method returns a Boolean value indicates whether the passed value is NaN and its type is Number.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<script>
var result = Number.isNaN("Hello");
document.write(result);
</script>
</body>
</html>
Syntax
Number.isNaN(value)
Parameter Values
Value | Type | Explanation |
---|---|---|
value | Required | The value to be tested for Not-a-Number (NaN). |
Return Value
Value | Explanation |
---|---|
true | If the given value is NaN and its type is Number. |
false | If the given value is not a NaN. |
More Examples
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<script>
document.write(Number.isNaN(NaN)+" :NaN <br>");
document.write(Number.isNaN(0 / 0)+" :0 / 0 <br><br>");
document.write(Number.isNaN(25)+" :25 <br>");
document.write(Number.isNaN(-25.5)+" :-25.5 <br>");
document.write(Number.isNaN(true)+" :true <br>");
document.write(Number.isNaN(false)+" :false <br>");
document.write(Number.isNaN('65')+" :'65' <br>");
document.write(Number.isNaN([5])+" :[5] <br>");
document.write(Number.isNaN(Infinity)+" :Infinity <br>");
document.write(Number.isNaN(-Infinity)+" :-Infinity <br>");
document.write(Number.isNaN(null)+" :null <br>");
</script>
</body>
</html>
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.