If two Objects added together equal NaN(not a number), which is technically of type number, then why does getting the type of two Objects added together result in "string"?
I will express this via the REPL:
> {} + {}
> NaN
ok. two objects added together creates NaN
> typeof(NaN)
> "number"
ok. we know that NaN's type is "number"
> typeof({} + {})
> "string"
wait. shouldn't this have been "number" also?
I'm aware that javascript has a less then desireable type system, but I'm confused as to what's happening here. Is the type being converted from number to string for some reason? Is number even a part of the type converting that goes on here? Or am I just using typeof wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…