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:

javascriptconsole.log('aaa' * 3);

The code execution result:

javascriptNaN

Example

Let's try to divide one string by another:

javascriptconsole.log('aaa' / 'bbb');

After executing the code, we will also get NaN:

javascriptNaN

Example

Now let's add the NaN value with a number:

javascriptconsole.log(NaN + 3);

The code execution result:

javascriptNaN

See also

  • the isNaN function
    that checks for NaN