box

undefined means a variable has been declared
but has not yet been assigned a value.
it exists, but it's empty.

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

Undefined: The Ghost

Imagine a box that exists, but you haven't put anything in it yet. When you declare a variable but don't assign a value, JavaScript gives it the value 'undefined'.

Null: The Intentional Void

Now imagine you put a label inside the box that says 'EMPTY'. That's null. It's a value that YOU assign to say 'this variable should have no value'.

The confusing part

Are they the same? Kind of. 'null == undefined' is true because they both represent emptiness. But 'null === undefined' is false because they are different types!

Emptiness Understood

You've grasped the subtle difference between "nothing yet" and "intentionally nothing".
Ready for super-sized integers?

AlgoAnimator: Interactive Data Structures