JavaScript Objects The Number Object- NaN - Javascript Objects

What is JavaScript Number – NaN?

Unquoted literal constant NaN represents Not-a-Number is a special value . Since NaN always compares unequal to any number, including NaN, it is normally used to indicate an error condition for a function which returns a valid number.

Note − Use the isNaN() global function to see if a value is an NaN value.

Syntax:

The syntax of NaN is −

var val = Number.NaN;

Example:

The following example shows how to use NaN.

Output:

Day of Month must be between 1 and 31.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Javascript Objects Topics