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 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 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"
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.
typeof null returns the string ____, which is a well-known quirk since null is not actually an object.
What does null represent?
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 →