NaN value
The NaN value (abbreviation
for Not-A-Number) means
"not a number". This value occurs
when trying to perform an invalid
mathematical operation.
Example
Let's multiply a string with letters by a number:
console.log('aaa' * 3);
The code execution result:
NaN
Example
Let's try to divide one string by another:
console.log('aaa' / 'bbb');
After executing the code, we
will also get NaN:
NaN
Example
Now let's add the NaN
value with a number:
console.log(NaN + 3);
The code execution result:
NaN
See also
-
the
isNaNfunction
that checks forNaN