Standard built-ins

Object.create()

Try the free JavaScript compiler

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

NameTypeDescription
protoObject | nullPrototype of the new object.
propertiesObjectObjectOptional 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"));
JavaScript Reference