4 ms·
Except in these cases, undefined still can make complete sense if you're willing to rephrase things (like sindresorhus is). For your Node.firstChild example, o
by Master_Odin 6y ago
Except in these cases, undefined still can make complete sense if you're willing to rephrase things (like sindresorhus is).
For your Node.firstChild example, one could say that if a node has no children, then it's firstChild is not defined as it doesn't exist, and so undefined makes sense. You can construct similar plausible arguments for other usages of null, though you cannot do the inverse.
- ZephyrBlu 6y agoNode.firstChild _is_ defined though, it's just empty. Hence null. An undefined property would be one like Node.helloWorld, which doesn't not exist at all on the object.
- chrismorgan 6y agoNode.firstChild producing null is this conversation: “Hey node, what’s your first child?” “I don’t have a first child.” Node.firstChild producing undefined is this conversation: “Hey node, what’s your first child?” “Huh? What’s a first child? I have no idea what you’re talking about.”