JS-007
Educational JavaScript lesson graphic for null: Learn what the null value means in JavaScript
Beginner2 min~2 min read#null#primitive-types#empty

null

Empty on purpose

Goal

Learn what the null value means in JavaScript.

Explanation

  • null is a special value that means an intentionally empty place.
  • It is used when a variable exists but currently holds no meaningful value.
  • This means the programmer deliberately assigned null to the variable.
  • For example, a user has not chosen a favorite color yet, or a product has not been assigned to a buyer.
  • null does not mean "unknown" — it means "empty on purpose".

Analogy

Imagine a table with a sign that says "Place for a vase." The vase is missing, but the spot was deliberately left empty. That is null.

Code

let favoriteColor = null;

console.log(favoriteColor);

Result: null

Common mistake

Do not confuse null with undefined. null is set by the programmer; undefined usually appears automatically.

Remember

  • null means an intentionally empty value.
  • The variable exists.
  • The value was deliberately set to null.

Quick Quiz

What does null mean?

Resources