Skip to content

Instantly share code, notes, and snippets.

@mturnwall
Last active December 14, 2015 06:18
Show Gist options
  • Save mturnwall/5041014 to your computer and use it in GitHub Desktop.
Save mturnwall/5041014 to your computer and use it in GitHub Desktop.
Object.create() polyfill since IE8 doesn't support the create() method.
/**
* Polyfill for Object.create()
* use this to create new objects
*/
if (!Object.create) {
Object.create = function (o) {
if (arguments.length > 1) {
throw new Error('Sorry the polyfill Object.create 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