undefined, JavaScript's Extra Flavor
JavaScript has a second kind of nothing, and this one has no Python equivalent at all.
null means someone deliberately set this to nothing.
undefined means nobody ever set this at all.
A variable you declare but never assign is undefined. An object property that doesn't exist is undefined. A function that returns nothing gives back undefined.
✦ Direct equivalent, similar concept, or language-specific?
Python None ↔ JavaScript null is a SIMILAR CONCEPT, safe to translate. JavaScript undefined is a LANGUAGE-SPECIFIC FEATURE with no Python counterpart. Don't force a false equivalence just to keep the two languages symmetrical. Real understanding means knowing where the map ends.
Mark this lesson complete
Signed in, your progress follows you to every device.