Created
May 10, 2015 20:44
-
-
Save sandeshdamkondwar/1a611dacb2eb4b692780 to your computer and use it in GitHub Desktop.
Object.create Polyfill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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