Implement Object.create

Med
Code
Loading editor...
Tap Analyze to see visualization
Variables

Run code to see variables

Output

Console output will appear here

Press Space to start to step? all shortcuts

Solution Guide: Implement Object.create

Approach

Create an empty constructor function F, set F.prototype to the desired proto object, then instantiate with new F(). This produces an object whose internal [[Prototype]] points to proto. Optionally apply property descriptors via Object.defineProperties for the second argument.

Complexity Analysis

Time
O(1)
Space
O(1)

Pattern

Prototype Delegation

Why It Works

Setting F.prototype before calling new F() ensures the new object has the correct prototype link. This is the classic polyfill pattern used before Object.create was standardized in ES5.

Updated Mar 2026