Course contentsShow
← JavaScript
Lesson 598 of 2,72315. ObjectsFree lesson

Empty Objects

Create and work with objects that start with no properties.

Empty Objects

You'll learn: how to create objects that start with no properties and why they're useful as blank slates.

What Is an Empty Object?

An empty object is exactly what it sounds like—an object literal with no properties inside the curly braces. It's like having an empty container ready to be filled later.

const emptyBox = {};

This creates a perfectly valid JavaScript object; it just doesn't contain anything yet.

Why Start Empty?

Sometimes you don't know what properties you'll need upfront. You might be:

  • Building an object dynamically based on user input
  • Collecting data in a loop
  • Creating a blank configuration that gets filled conditionally

Think of it like an empty backpack. You can pack it later based on what you need for your trip.

Adding Properties Later

Since objects are reference types (as you learned), you can add properties to an empty object after creating it:

const user = {};

user.name = "Alice";
user.age = 25;

console.log(user); // { name: "Alice", age: 25 }

You can use either dot notation or bracket notation:

const settings = {};

settings["theme"] = "dark";
settings.notifications = true;

Common Pattern: Accumulating Data

Empty objects shine when collecting data:

const scores = {};

scores.math = 95;
scores.science = 88;
scores.history = 92;

Key Takeaway: Empty objects ({}) are valid starting points that let you build up properties dynamically as your program runs, giving you flexibility when you don't know the final structure upfront.