The language specification explicitly says:
If x is null and y is undefined, return true
I'm not aware of any records of the language design process that explain the reasoning for that decision, but ==
has rules for handling different types, and "null" and "undefined" are both things that mean "nothing", so having them be equal makes intuitive sense.
(If you don't want type fiddling, use ===
instead).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…