The JavaScript Object.create() method
The Object.create() method creates a new object using an existing object as its prototype. Object.create(proto) makes an object that inherits from proto. It's the low-level tool behind prototypal inheritance; Object.create(null) makes a "clean" object with no prototype, useful as a pure key-value map.
Overview
Object.create() builds a new object and sets its prototype to whatever you pass. The new object inherits properties and methods from that prototype through the chain. This is JavaScript's inheritance mechanism at its most direct — classes are a friendlier syntax layered on top of this same prototype model.
Two practical uses stand out. First, prototypal inheritance without classes: const dog = Object.create(animalProto) makes dog inherit animalProto's methods. Second, and more common in everyday code, Object.create(null) creates an object with no prototype at all — a truly empty "dictionary" that doesn't inherit toString, hasOwnProperty or anything else. That makes it a safe pure key-value store where user-supplied keys can't collide with inherited method names.
An optional second argument lets you define properties with full descriptors (value, writable, enumerable, getters/setters), though that's rarely needed day to day. For most object creation you'll just use a literal {}, and for structured types a class is clearer than hand-rolling prototypes. Reach for Object.create() when you specifically need to control the prototype — most often Object.create(null) for a clean map.
Syntax
Object.create(proto)
Object.create(proto, propertiesObject)
const child = Object.create(parentObject); // inherits from parent
const map = Object.create(null); // no prototype - clean dictionary
Parameters
The Object.create() method accepts the following parameters.
| Parameter | Description |
|---|---|
proto |
The object to use as the new object's prototype, or null for no prototype. |
propertiesObject |
Optional. Property descriptors to add to the new object (value, writable, get/set, etc.). |
Example
<pre id="out" style="font:15px ui-monospace,monospace"></pre>
<script>
const animal = { speak() { return this.sound + '!'; } };
const dog = Object.create(animal);
dog.sound = 'Woof';
const clean = Object.create(null);
clean.key = 'value';
document.getElementById('out').textContent =
'dog.speak(): ' + dog.speak() + '\n' +
'clean has toString? ' + ('toString' in clean);
// dog.speak(): Woof! / clean has toString? false
</script>
Best practices
- Use
Object.create(null)for a clean key-value map with no inherited keys. - Use it for direct prototypal inheritance when you don't want a class.
- For most object creation, a literal
{}is simpler; for structured types, prefer a class. - Remember objects from
Object.create(null)lack methods likehasOwnProperty— use Object.hasOwn() instead.
Frequently asked questions
What does Object.create() do?
What is Object.create(null) used for?
toString.What is the difference between Object.create() and a class?
Object.create() works directly with prototypes.