JavaScript uses undefined for a value that has not been assigned, was omitted, does not exist, or was never returned. That differs from null, which signals deliberate emptiness. The distinction exposes whether nobody supplied an answer or the program explicitly found no value. section 4.1 section 6.1.2
Use undefined for states that remain unset or unanswered:
- Uninitialized variables, omitted function arguments, nonexistent properties, and functions without a return value. section 4.1
- Check explicitly with === undefined when the distinction from null matters. section 4.1
- Use val == null when either undefined or null should count as no value. section 4.1
- Treat undefined as falsy, alongside null, false, numeric zero, NaN, and the empty string. section 4.6
Separate unset from intentionally empty
const record = { note: null, status: undefined }; record.note === null; // true: deliberately empty record.status === undefined; // true: not yet assigned function processValue(value) { if (value === undefined) return 'not set'; if (value == null) return 'no value'; return `processing ${value}`; } section 4.1
function processValue(val) {
if (val === undefined) { #A
return 'not set'; #A
} #A
if (val == null) { #B
return 'no value'; #B
} #B
return `processing ${val}`; #C
}Trace a practical classifier that handles undefined first, then groups null with other absent values through deliberate loose equality. section 4.1

