JavaScript Object.create() Method

Definition
Object.create(proto) makes a new empty object whose prototype is proto. The new object inherits methods and properties from that prototype.
You can pass a second argument with property descriptors, or use Object.create(null) for an object with no prototype chain.
Syntax
Call Object.create() like this. Start with this line.
Object.create(proto)
Object.create(proto, propertiesObject)
| Call | What it does |
|---|
Object.create(proto) | Creates a new object that inherits from proto. |
Object.create(proto, propertiesObject) | Same, and also defines own properties from descriptors. |
Built into JavaScript. Call on Object — no import required.
Library declarations
Object.create(proto, propertiesObject)
create(o: object | null, properties?: PropertyDescriptorMap): any;
Parameters
| Parameter | Description |
|---|
| proto | Required. The object to use as the new object's prototype, or null for no prototype. |
| propertiesObject | Optional. An object of property descriptors, like the map used by Object.defineProperties(). |
Return Value
| Return Value | Description |
|---|
| object | A new object linked to the given prototype. |
JavaScript Examples
Example 1 — Basic Use
Create an object that inherits a method from a prototype.
var proto = {
greet: function () {
return "hi";
}
};
var obj = Object.create(proto);
console.log(obj.greet()); // hi
console.log(Object.getPrototypeOf(obj) === proto); // true
console.log(obj.hasOwnProperty("greet")); // false
How It Works
- Make a prototype.
proto holds a greet method. - Link a new object.
Object.create(proto) returns an empty object that inherits from proto. - Inherited, not own.
greet works, but hasOwnProperty("greet") is false.
Example 2 — Null Prototype
Use null as the prototype when you want a clean bag of keys.
var blank = Object.create(null);
blank.name = "Ada";
console.log(blank.name); // Ada
console.log(Object.getPrototypeOf(blank) === null); // true
How It Works
- No prototype.
Object.create(null) starts with no inherited methods. - Own data only. You can still add your own properties, like
name. - Check the link.
getPrototypeOf returns null for this object.
Example 3 — With Property Descriptors
The second argument defines own properties while the first sets the prototype.
var base = { role: "guest" };
var user = Object.create(base, {
name: {
value: "Sam",
writable: true,
enumerable: true,
configurable: true
}
});
console.log(user.name); // Sam
console.log(user.role); // guest
console.log(user.hasOwnProperty("name")); // true
console.log(user.hasOwnProperty("role")); // false
How It Works
- Own property.
name is defined on user itself. - Inherited property.
role comes from base through the prototype. - Own vs inherited.
hasOwnProperty is true for name and false for role.
Compatibility
Browser & Runtime Support
Object.create() has been part of JavaScript since ES5 and is Baseline Widely available everywhere modern code runs.
✓ Baseline · ES5
Object.create()
Supported in all modern browsers and Node.js. Internet Explorer 9+ also includes it.
99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full supportObject.create Excellent
Bottom line: Use Object.create() freely. It works in every current browser and runtime.
Frequently Asked Questions
It creates a new object whose prototype is the object you pass in. The new object starts empty unless you also pass property descriptors.
{} creates an object that inherits from Object.prototype. Object.create(proto) lets you choose any prototype, including null.
It makes a plain dictionary with no inherited methods. That avoids clashes with keys like toString or constructor.
No. It only sets the prototype link. Properties stay on the prototype until the child shadows them.
Yes. Assign them normally, or use Object.defineProperty / Object.defineProperties for more control.
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful