Reputation: 4588
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.
Upvotes: 1
Views: 162
Reputation: 23208
I modified your jsfiddle
You were using bookPrice
instead of this.price
Upvotes: 3
Reputation: 43168
Trying alert(typeof NaN)
might be illuminating.
Although NaN
literally means "not a number", it actually is a kind of number
. Its meaning is "not a valid number" (in the sense of mathematical numbers), but it is still a number
value (in the sense of Javascript types).
Upvotes: 2