JavaScript Number isNaN() method

Definition and usage

In JavaScriptNaN Is the abbreviation of "Not-a-Number".

In JavaScriptNaN It is an invalid number.

If the value is NaN and the type is Number Number.isNaN() Method returns true.

See also:

NaN() property

Global isNaN() method

Example

Example 1

Check if the value is Number.NaN:

Number.isNaN(123);
Number.isNaN(-1.23);
Number.isNaN('123');
Number.isNaN(0/0);

Tsa kai kai ko tsa

Example 2

Number.isNaN(5-2);
Number.isNaN(0);
Number.isNaN('Hello');
Number.isNaN('2005/12/12');
Number.isNaN(' ');

Tsa kai kai ko tsa

Example 3

Check if the value is Number.NaN:

Number.isNaN(false);
Number.isNaN(true);
Number.isNaN(undefined);
Number.isNaN('NaN');
Number.isNaN(NaN);

Tsa kai kai ko tsa

Syntax

Number.isNaN(value)

Parameter

Parameter Description
value Required. The value to be tested.

Return value

Type Description
Boolean value. If the value is Number.NaN true; otherwise false

Difference between isnan() and Number.isnan()

IfValueIf it is not a number: isNaN() Method returns true

IfNumberIf it is not a number: Number.isNaN() Return true

In other words:isNaN() Before the test, convert the value to a number.

Example

isNaN('Hello');		// Return true

Tsa kai kai ko tsa

Number.isNaN('Hello');	// Return false

Tsa kai kai ko tsa

Browser daa yin

Number.isNaN() a jina ECMAScript6 (ES6) daa yin.

Alla browsers daa yin a daa yin ES6 (JavaScript 2015):

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
a daa yin a daa yin a daa yin a daa yin a daa yin

Internet Explorer 11 (tana da kai ko ko tsa) ba a daa yin a girmi Number.isNaN()