in JavaScript by
Q:
What is NaN property in JavaScript?

1 Answer

0 votes
by
NaN property represents “Not-a-Number” value. It indicates a value which is not a legal number.

typeof of a NaN will return a Number .

To check if a value is NaN, we use the isNaN() function,

**Note- isNaN() function converts the given value to a Number type, and 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
Click here to read more about JavaScript
Click here to read more about Insurance

Related questions

0 votes
0 votes
asked Dec 10, 2020 in JavaScript by SakshiSharma
0 votes
asked Oct 19, 2019 in JavaScript by SakshiSharma
0 votes
asked Feb 6, 2020 in JavaScript by rajeshsharma
0 votes
asked Jan 27, 2020 in JavaScript by AdilsonLima
+1 vote
asked Dec 4, 2019 in JavaScript by SakshiSharma
...