Trivia Questions1 min readPremium

What’s the difference between Object.create and new? MDN documents Object.create() and the new operator.

Understanding Object.create and new in JavaScript

In JavaScript, Object.create and the new keyword are two prevalent methods for creating objects, each with distinct mechanisms and implications for object initialization and prototype chain setup.

Object.create allows for the creation of a new object with a specific prototype object and optionally defined properties. It’s invoked as Object.create(proto, [propertiesObject]), where proto is the prototype object the new object should inherit from, and propertiesObject is an optional descriptor for the new object’s own properties. A notable benefit of Object.create is its ability to create a new object with a chosen prototype without invoking any constructor function.

In contrast, the new keyword is used to instantiate a new object from a constructor function. Invoking a function with new (new Constructor()) does several things: it creates a new object, sets this object’s prototype to the constructor function’s prototype, executes the constructor function with this bound to the new object, and finally, if the function doesn’t explicitly return an object, the new object is returned by default.

Object.create vs new: Key Differences

One of the fundamental differences is in their approach to prototype assignment... premium content.

Premium

Keep reading with Premium

Get the rest of this guide plus every premium question, solution, and system design deep dive.

  • All premium solutions
  • System design deep dives
  • Company-specific prep

4.9/5 from our users