English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
isNaN()Method determines whether the passed value is NaN (Not-A-Number).
If the type of the value is Number, this method returns true and equals NaN; otherwise, it returns false.
This method is different from the globalisNaN()Function.
GlobalisNaN()Function, which converts the tested value to Number and then tests it.
Number.isNaN() does not convert the value to Number and will not return true for any non-Number type values.
Number.isNaN(value)
Number.isNaN(451); // false Number.isNaN(-3.13); // false Number.isNaN(3-1); // false Number.isNaN(0); // false Number.isNaN("451); // false Number.isNaN("Hello"); // false Number.isNaN("20/12/2018); // false Number.isNaN(&39&;39;);// false Number.isNaN(true); // false Number.isNaN(undefined); // false Number.isNaN(&39;NaN&39;); // false Number.isNaN(NaN); // true Number.isNaN(0 / 0); // trueTest See </›
The numbers in the table specify the first browser version that fully supports the isNaN() method:
Method | |||||
isNaN() | 19 | 16 | 15 | 9 | 12 |
Parameter | Description |
---|---|
value | The NaN Value to Test |
Return Value: | If the given value is NaN and the type is Number, it returns true; otherwise, it returns false |
---|---|
JavaScript Version: | ECMAScript 6 |