I have a function that when the return statement is prefaced with typeof it says it’s a number. But when I remove it it outputs NaN.
I don’t understand why.
Here’s a fiddle:
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Trying
alert(typeof NaN)might be illuminating.Although
NaNliterally means “not a number”, it actually is a kind ofnumber. Its meaning is “not a valid number” (in the sense of mathematical numbers), but it is still anumbervalue (in the sense of Javascript types).