What is NaN property in JavaScript?

Forums JavaScriptWhat is NaN property in JavaScript?
Staff asked 2 years ago

Answers (1)

Add Answer
Nayan Raval Marked As Accepted
Staff answered 2 years ago

The “Not-a-Number” value is represented by the NaN attribute. It denotes a value that isn’t a valid number.

A Number will be returned if typeof is applied to a NaN.

The isNaN() method is used to determine if a value is NaN.

**Note: The isNaN() function converts a value to a Number type, which it then equates to NaN.

isNaN("Hello")  // Returns true
isNaN(345)   // Returns false
isNaN('1')  // Returns false, since '1' is converted to Number type which results in 0 ( a number) 
isNaN(true) // Returns false, since true converted to Number type results in 1 ( a number)
isNaN(false) // Returns false
isNaN(undefined) // Returns true

 

Subscribe

Select Categories