Skip to content

Instantly share code, notes, and snippets.

@lavoiesl
Created September 20, 2013 18:49
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save lavoiesl/6642066 to your computer and use it in GitHub Desktop.
Save lavoiesl/6642066 to your computer and use it in GitHub Desktop.
Javascript Object.create() polyfill
// http://jsperf.com/new-vs-object-create-including-polyfill
if (typeof Object.create !== 'function') {
Object.create = function(o, props) {
function F() {}
F.prototype = o;
if (typeof(props) === "object") {
for (prop in props) {
if (props.hasOwnProperty((prop))) {
F[prop] = props[prop];
}
}
}
return new F();
};
}
@steelx
Copy link

steelx commented Feb 24, 2017

Can you show an example usages. Since this is accepting different arguments than MDN polyfill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment