If you want an actual reason not to have two non-values, it's that this just seems very arbitrary.
I don't think it seems arbitrary at all. The language specification is not arbitrary when it describes null as meaning something explicitly set and undefined meaning something, well, undefined. Just because they both evaluate to "falsey" doesn't mean there's not a clear difference to their actual meaning. The reason those two exist (and not three or four or five) is because there's not another clear cut solidly-defined use case for it. But for both null and undefined, they both have a clear unambiguous meaning and plenty of use cases.
You misunderstood my point; both null and undefined are not at all arbitrarily defined; what is arbitrary is exactly having two of them.
If you're going to distinguish non-values of different kinds, why only two? Why not add a third one for "no selection", or a NaN-like value for "unknown" values? And I'm sure many problem domains would come up with their own non-values that make absolute sense to distinguish from nullandundefined.
As I said, at that point a more elegant solution would be adding FalseySymbol or NullishSymbol or both and leave it up for the user to define specific non-values that hold whatever semantic meaning they want.
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I don't think it seems arbitrary at all. The language specification is not arbitrary when it describes
nullas meaning something explicitly set andundefinedmeaning something, well, undefined. Just because they both evaluate to "falsey" doesn't mean there's not a clear difference to their actual meaning. The reason those two exist (and not three or four or five) is because there's not another clear cut solidly-defined use case for it. But for bothnullandundefined, they both have a clear unambiguous meaning and plenty of use cases.You misunderstood my point; both
nullandundefinedare not at all arbitrarily defined; what is arbitrary is exactly having two of them.If you're going to distinguish non-values of different kinds, why only two? Why not add a third one for "no selection", or a NaN-like value for "unknown" values? And I'm sure many problem domains would come up with their own non-values that make absolute sense to distinguish from
nullandundefined.As I said, at that point a more elegant solution would be adding
FalseySymbolorNullishSymbolor both and leave it up for the user to define specific non-values that hold whatever semantic meaning they want.