Skip to content

Instantly share code, notes, and snippets.

@sandeshdamkondwar
Created May 10, 2015 20:44
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 sandeshdamkondwar/1a611dacb2eb4b692780 to your computer and use it in GitHub Desktop.
Save sandeshdamkondwar/1a611dacb2eb4b692780 to your computer and use it in GitHub Desktop.
Object.create Polyfill
if (typeof Object.create != 'function') {
Object.create = (function() {
var Temp = function() {};
return function (prototype) {
if (arguments.length > 1) {
throw Error('2nd argument is not supported');
}
if (typeof prototype != 'object') {
throw TypeError('argument should be object');
}
Temp.prototype = prototype;
var result = new Temp();
Temp.prototype = null;
return result;
};
})();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment