Skip to content

Instantly share code, notes, and snippets.

@newswim
Created November 17, 2016 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save newswim/31cb0da08bb48dbc4a89149ef4606c22 to your computer and use it in GitHub Desktop.
Save newswim/31cb0da08bb48dbc4a89149ef4606c22 to your computer and use it in GitHub Desktop.
Object.create simple polyfill
/**
* @param {object} o - this object will be the Prototype of the newly created object.
*/
if (!Object.create) {
Object.create = function (o) {
if (arguments.length > 1) {
throw new Error('Object.create implementation only accepts the first parameter.');
}
function F() {}
F.prototype = o;
return new F();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment