What is the output of the following code: console.log(typeof NaN);?
a)
"undefined"
b)
"number"
c)
"object"
d)
"NaN"
Answer:
b)
"number"
Explanation:
In JavaScript, NaN
stands for “Not-a-Number”, but it is still considered a numeric value. When checking the type of NaN
using typeof
, the result is "number"
.