Standard built-ins
Object.create()
Creates an object with the specified prototype; optional descriptors define own properties. Does not copy prototype properties.
Formal Syntax & Structure
javascript syntaxjavascript
Object.create(proto, [propertiesObject])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| proto | Object | null | Prototype of the new object. |
| propertiesObject | Object | Optional mapping of own enumerable keys to descriptors. |
Return Value
Object
New object with requested prototype.
Working Example
Example Snippetjavascript
const x=Object.create({n:2});console.log(x.n,Object.hasOwn(x,"n"));