undefined and null
In short: JavaScript has two different "empty" values, and they mean
different things. undefined is what the engine gives you when
something was never set — a missing property, an unassigned variable, a
function that falls off the end without a return. null is what a
person writes on purpose to say "this is deliberately empty." Mixing the
two up leads to checks that look right but miss half the cases.

A song with no album yet
A song object can have a field a person filled in as empty, and a field nobody ever added at all — they read very differently:
song.album is null: someone decided this song has no album and recorded
that fact. song.year is undefined: the property was never added, so the
engine has nothing to report. Same "empty" feeling, opposite origin.
The data
const song = { title: "Blue Hour", album: null };
A function that forgets to return
Every function returns something, even when its body doesn't say so:
logPlay never has a return, so calling it gives undefined back — the
engine's default answer when you ask a function for a value it didn't
promise one. This is the single most common way undefined shows up by
accident: a forgotten return.
Reading a property of nothing
The real danger isn't the empty value itself — it's reaching into one:
song.year is undefined, and undefined has no properties, so
.length throws a TypeError. The fix is to check first:
song.year ? song.year.length : 0, or the shorter song.year?.length,
which returns undefined instead of throwing when the left side is
missing.
One-liners worth knowing: null == undefined is true (loose equality
treats them as the same kind of empty), but null === undefined is false
(different types). typeof null is "object" — a decades-old leftover bug
kept for compatibility — while typeof undefined is "undefined".
Quick practice
What does let next; console.log(next); log?
A form's JSON has no discount field at all. What does order.discount give?
A developer wants to record "this user has no referrer, and we checked" — which value should they write?
What do null == undefined and null === undefined evaluate to?
