PL design is complicated and you pretty much have to keep this kind of quirks forever or at least for a very long time if you want to avoid a painful transition, which can lead to the old language version hanging out forever in the wild because a lot of code is already written in it. You can deprecate the features the quirks affect and introduce new ones to replace them that do not have the quirks, but now you need to support both ways for a very long time until the ecosystem is ready, which may never happen.
there's nothing wrong with:
switch (typeof v) {
...
case ...:
...
break;
case "undefined":
// handle undefined;
break;
case "object":
if (!v) {
// handle null;
} else if (v instanceof 'Array') {
// handle array;
} else if (...) {
...
} else {
// handle anything else
}
break;
}
that's within the spec and an alternative could be more verbose / more difficult to navigate (it's a matter of taste). If you need to handle undefined and null differently, you need to test for it and typeof === "object" is one way. I would probably do it differently, but I can see someone thinking differently and we can't blame them.If you rely on any frameworks or libraries whatsoever, you can't assume they aren't using null in this way and would break if the language spec changed. The only common ground you and those developers have is the language specification's rules.
(If you actually do roll all your JS by hand in house, congratulations and I'm impressed, but (a) that's a minority position in any house that has to do professional JavaScript and (b) oh wow you're reinventing a lot of wheels).
if (typeof varname === "object" && !varname) { loggingNull("varname"); }
it seems far fetched and maybe those people's code should break.
I guess it doesn't really affect me though.