• undefined: It doesn’t exist at all. In grug-speak undefined is “very nothing”
  • null: It (kind of) exists, but it’s empty. In grug-speak null is “kinda nothing”

There are some practical differences between the two, the primary one being that undefined is the default value of a variable when it hasn’t been given a value yet in source

let myName;
console.log(myName); // undefined

To get a null value, you have to explicitly assign it:

let myName = null;
console.log(myName); // null

Confusingly, typeof returns "object" for null:

console.log(typeof null); // object

To be clear, null is its own type according to the ECMAScript specification, but the “object” type report is a historical quirk that can’t be easily fixed now.

In most cases, null and undefined work the same way, but you’ll want to be consistent in how you use them, and know that there are subtle behavioral differences.