Skip to content

Instantly share code, notes, and snippets.

@niceaji
Forked from lavoiesl/object.create.js
Created May 10, 2014 12:33
Show Gist options
  • Save niceaji/68441f5541db59a06cc7 to your computer and use it in GitHub Desktop.
Save niceaji/68441f5541db59a06cc7 to your computer and use it in GitHub Desktop.
// 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();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment