console.log(typeof NaN)
The above returns 'number'.
Q1. How do I find a way around this?
Q2. What is a better way to find the type of a variable? (instead of typeof
)
Thanks!
Update: Thank you for all your comments. But the first answerer understood my question. I was concerned about assessing the type of a return statement of 'NaN' to not show up as a 'Number'.
I was using typeof() in an if statement to act when if(typeof(x) == "number") { do this.. }
But the condition passed even though x was NaN. I wanted to resolve this.
I did not know 'NaN' was of type 'Number' cause NaN means 'Not a Number'. That led to confusion.
I apologize for not being clear on what I wanted to ask. But my issue is solved.
Thanks everyone!