This JavaScript tutorial explains how to use the Number property referred to as NaN with syntax and examples.
Description
In JavaScript, NaN is a static property of the Number object that is used to return the value that represents Not-A-Number (ie: NaN). Because NaN is a property of the Number object, it should be invoked thru the object known as Number.
Syntax
In JavaScript, the syntax for the NaN property is:
Number.NaN;
Parameters or Arguments
There are no parameters or arguments for the NaN property.
Returns
The NaN property returns the fee that represents Not-A-Number which is NaN.
Note
The NaN property is a property of the Number object and no longer a range function. However, we have included the NaN property within our JS Number Methods part because you will most likely use this property in conjunction with the Number methods observed in this section.
Example
Let’s take a appear at an example of how to use the NaN property in JavaScript.
For example:
console.log(Number.NaN);
In this example, we have invoked the NaN property using the Number class.
We have written the output of the NaN property to the net browser console log, for demonstration purposes, to show what the NaN property returns.
The following will be output to the web browser console log:
NaN
In this example, the NaN property returned a cost of NaN which represents Not-A-Number in JavaScript.
Leave a Review