.isNaN()
ketanSaraf00665459128 total contributions
Published Oct 7, 2021Updated Oct 12, 2021
Contribute to Docs
The Number.isNaN()
method is part of the Number
class in JavaScript.
It accepts a single argument, value
, and returns true
if the passed argument is NaN (“Not a Number”), and returns false
, otherwise.
Syntax
Number.isNaN(value);
value
(required): The value to check.
Example 1
To verify if 0 / 0
is NaN:
const x = 0 / 0;console.log(Number.isNaN(x));// Output: true
The square root of a negative number would return NaN, so it would return true
.
Example 2
To verify if 5
is NaN:
const y = 5;console.log(Number.isNaN(y));// Output: false
It would return false
because 5 is a number.
Codebyte Example
All contributors
- ketanSaraf00665459128 total contributions
- Anonymous contributorAnonymous contributor3071 total contributions
- ketanSaraf0066545912
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.