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

Object Literals vs. new Object()

Learn why object literal syntax is preferred over the Object constructor.

Object Literals vs. new Object()

You'll learn why the literal syntax {} is the standard way to create objects in JavaScript, not new Object().

Two Ways to Create an Empty Object

JavaScript gives you two ways to create an empty object:

// Object literal syntax (preferred)
const person1 = {};

// Constructor syntax (avoid)
const person2 = new Object();

Both create an empty object, but they're not equal in practice.

Why Object Literals Win

Readability: The literal syntax {} is clean, concise, and instantly recognizable. new Object() is verbose and looks like legacy code.

Performance: Object literals are slightly faster because they don't require a constructor function call. Modern engines optimize both, but literals have the edge.

Consistency: When you want properties immediately, literals are far cleaner:

// Literal: elegant and clear
const dog = {
  name: "Buddy",
  age: 3
};

// Constructor: awkward and clunky
const cat = new Object();
cat.name = "Whiskers";
cat.age = 2;

Convention: Every style guide and experienced developer uses literals. Using new Object() signals unfamiliarity with modern JavaScript practices.

Think of It Like This

Imagine two ways to make a sandwich: grab two slices of bread and add filling (literal), or call a sandwich-making factory that ships you bread, then you add the filling yourself (constructor). The first way is obviously better.

When You Might See new Object()

You won't see it in good modern code. It exists mainly for historical reasons and internal engine operations. Stick with literals.

Key Takeaway: Always use object literal syntax {} to create objects—it's cleaner, faster, and the universally accepted standard in JavaScript.