A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-number-isnan-method/ below:

JavaScript Number.isNaN() Method - GeeksforGeeks

JavaScript Number.isNaN() Method

Last Updated : 06 Jun, 2024

In JavaScript NaN is stand for Not-a-Number. The Number.isNaN() method returns true if a value is NaN. This method checks whether the passed value is NaN and of type Number, ensuring accurate identification of invalid numeric values.

Syntax

Number.isNaN(value)

Parameters

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. 

Example 1: In This example the GFGFun() function initializes an empty string res. It then appends the result of the Number.isNaN(123) method call to res. Since 123 is a valid number, Number.isNaN() returns false.

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

Example 2: In this example the GFGFun() function initializes an empty string res. It then appends the result of the expression Number.isNaN(0 / 0) to res. Since division by zero results in NaN, Number.isNaN() returns true.

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

Example 3: In this example the function GFGFun() initializes an empty string res, then appends the result of Number.isNaN(321) to res. Since 321 is a valid number, Number.isNaN() returns false.

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

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

Supported Browsers:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4