Objective

Create a polyfill for the static Object.create() method.

Difficulty

Easy

Description

In the JavaScript Objects — Prototypes chapter, we saw the Object.create() method and that how it enables one to create an object with a given prototype.

Object.create() isn't supported on old browsers, likewise to get it to work in them, we have to create a polyfill for the method.

In this exercise, you have to create a polyfill function objectCreatePolyfill() for Object.create().

It doesn't have to be a full-fledge polyfill, just have support for first proto argument. That's it.

It's not required for your polyfill to accept the second parameter of Object.create(), however if you wish to, you could — it's very easy to implement that as well.

The function objectCreatePolyfill() has the same behavior as Object.create(). Here's how it should work:

var a = { x: 10, y: 20 };
undefined
var b = objectCreatePolyfill(a);
undefined
b.x
10
b.y
20