I have practiced Javascript for a long long time,
and there's always a contradiction, which has confused me so much.
That is, why NaN and Infinity are both types of “number”?
In mathematics,“Infinity”is just a concept, not a number.
“NaN”means“Not a number”on its literal meaning.
Obviously those are not“numbers.”
However, in Javascript, both“NaN”and“Infinity”are“number.”
You can try it like below:
typeof NaN // Returns“number”
typeof Infinity // Returns“number”
So what's the reason?
Could someone tell me the reason about this weird contradiction?