undefined means a value was never assigned, while null is an explicit "no value". JavaScript produces undefined on its own, and null comes from your code or from APIs such as document.getElementById() when nothing matches.
A variable that is declared but not assigned is undefined, and so is a function parameter the caller did not provide. A missing object property and a function with no return also give undefined. null is an intentional assignment that marks a value as empty.
The two are loosely equal but not strictly equal, so null == undefined is true and null === undefined is false. typeof undefined is "undefined", but typeof null is "object", a legacy quirk.
let a; // undefined
let b = null; // null
typeof undefined; // "undefined"
typeof null; // "object" (legacy quirk)
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓