Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Absence of Value & Conversion · Lesson 14 of 15

undefined

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

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

🤖
undefined is JavaScript's default answer for 'nothing here yet.' 📭

undefined is the value JavaScript automatically gives to a variable that has been declared but not yet assigned a value. It means "nothing has been put here yet" — and unlike null, you rarely assign it yourself.

let score;
console.log(score); // undefined
score was declared with let but never given a value, so JavaScript reports it as undefined.

undefined also shows up automatically in other places — for example, when you access an object property that doesn't exist, or call a function that doesn't explicitly return anything.

const user = { name: 'Ada' };
console.log(user.age); // undefined
Accessing a missing property returns undefined instead of causing an error.
🤖
undefined vs null is one of the most-asked questions about JavaScript. Now you know. 🎓

The key difference: undefined means a value was never assigned — it's JavaScript's own default for "empty." null means a developer deliberately set "no value" on purpose. Think of undefined as "empty by default" and null as "emptied intentionally."

let a;
let b = null;
console.log(a); // undefined - never assigned
console.log(b); // null - deliberately set to "nothing"
a was simply never given a value; b was explicitly set to null.
Fill in the blank

A variable that has been declared but never given a value automatically holds ____.

Quick check

What is the key difference between null and undefined?

True or false

Accessing a property that doesn't exist on an object returns undefined rather than causing an error.

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 →