Why is `null + 1 = 1` but `undefined + 1 = NaN`?
问题 null + 1 = 1 undefined + 1 = NaN I am not able to understand what is the logic behind this. Shouldn't both have returned same result? 回答1: Basically, because that's what the language spec says - looking at ToNumber: Type Result Null +0 Undefined NaN And NaN + anything is NaN This might make some sense from the language perspective: null means an explicit empty value whereas undefined implies an unknown value. In some way - zero is the "number empty value" since it is neutral to addition. That