|
|
|
|
|
by crdrost
8 days ago
|
|
If you're a type purist then undefined looks nicer... It'd be like being upset at booleans because things get coerced to them or some 'ish. No: it's the type that has one inhabitant—it's not that type's fault that it appears as a default argument or var or was left out of JSON... So long as typeof null === "object", null is the absurd one |
|
Of course you shouldn't do that, but I once encountered a library that behaved differently depending on whether an option in an options bag object was not present or explicitly set to undefined.
You can run into similar ugliness with function parameters, if you do evil things like using
And of course you can explicitly check keys of objects, including parameters that are going to be destructured.All not things you should do, but taints the "purity" argument, doesn't it? :D