Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Absence of Value & Conversion · Lesson 13 of 15

null

A free lesson from Swipe Coding · JavaScript, level 2 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
null looks like nothing, but it's a value you choose on purpose — that's the whole trick to it. 🕳️

null is a special value that represents the intentional absence of any value. You assign it yourself to explicitly say "this variable has no value on purpose."

let selectedUser = null;
console.log(selectedUser); // null
null explicitly marks "no value" rather than leaving the variable unset.
🤖
This one's a genuine bug that's been frozen in place since the 90s. 🐛

null is one of JavaScript's primitive values, but oddly, typeof null returns "object" — a long-standing bug baked into the language from its earliest days. It can never be fixed without breaking huge amounts of existing code, so it's best to just memorize it as a quirk.

console.log(typeof null); // "object"
A famous historical JavaScript quirk — null itself is not actually an object.

Use null when you want to clearly signal that a value is absent by design — for example, resetting a variable, or representing "no selection yet." This makes your intent much clearer to future readers than simply leaving something unassigned.

Fill in the blank

typeof null returns the string ____, which is a well-known quirk since null is not actually an object.

Quick check

What does null represent?

True or false

typeof null correctly returns the string 'null'.

Keep your streak going in Swipe Coding

Swipe through every level of JavaScript on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.

Get the Swipe apps →