Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

JavaScript Number.isNaN() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The Javascript Number.isNan method in JavaScript is used to determine 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: 

  • Value: It is the value that 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. 

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

Example 1: This example checks if 123 is a number or not.

Javascript




function GFGFun() {
    let res = "";
    res = res + Number.isNaN(123);
    console.log(res);
}
GFGFun();

Output:

false

Example 2: When an equation resulting in an infinite value is passed as a parameter. 

Javascript




function GFGFun() {
    let res = "";
    res = res + Number.isNaN(0 / 0);
    console.log(res);
}
GFGFun();

Output:

Output : true

Example 3: When a number is passed as a parameter. 

Javascript




function GFGFun() {
    let res = "";
    res = res + Number.isNaN(321);
    console.log(res);
}
GFGFun();

Output:

Output : false

Example 4: When a number in string representation is passed as a parameter. 

Javascript




function GFGFun() {
    let res = "";
    res = res + Number.isNaN(213);
    console.log(res);
}
GFGFun();

Output:

Output : false

Example 5: When a string is passed as a parameter. 

Javascript




function GFGFun() {
    let res = "";
    res = res + Number.isNaN("hello");
    console.log(res);
}
GFGFun();

Output:

Output : false

Example 5: When Nan is passed as a parameter. 

Javascript




function GFGFun() {
    let res = "";
    res = res + Number.isNaN(NaN);
    console.log(res);
}
GFGFun();

Output:

Output : true

We have a complete list of Javascript Number Object methods, to check those please go through this Javascript Number Complete reference article.

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
Last Updated : 22 May, 2023
Like Article
Save Article
Similar Reads
Related Tutorials