English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript NaN Property

 JavaScript Global Properties/Function

GlobalNaNThe property represents 'Not'-A-The value of 'Number' (not a number).

For example, if you try to multiply a number by a string, the returned value is 'NaN'.

The initial value of NaN is Not-A-Number, withNumber.NaNof the same value.

UsingisNaN()Function to check if the value is NaN.

Syntax:

NaN
var ans = 10 * 'Hello';
;document.getElementById('result').innerHTML = ans;
Test See‹/›

Browser Compatibility

All browsers fully support the NaN property:

Property
NaNYesYesYesYesYes

Technical Details

Writable:None
Enumerable:None
Configurable:None
JavaScript Version:ECMAScript 1

More Examples

Check if the value is NaN using the isNaN() function:

var str = 'Hello world';
var ans = Number(str);   // Convert a string to a number
;if (isNaN(ans)) {
   ;document.getElementById('result').innerHTML = ans;
}
Test See‹/›

 JavaScript Global Properties/Function