-
-
Save adriancmiranda/c1eea5364bea552c171e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Object.create Partial Polyfill | |
// Support for second parameter is non-standard | |
if (typeof Object.create !== 'function') { | |
Object.create = function(o, props) { | |
var instance, prop; | |
// Create new object whose prototype is o | |
function F() {} | |
F.prototype = o; | |
instance = new F(); | |
// Copy properties of second parameter into new object | |
if (typeof(props) === "object") { | |
for (prop in props) { | |
if (props.hasOwnProperty((prop))) { | |
// Even though we don't support all of the functionality that the second | |
// parameter would normally have, we respect the format for the object | |
// passed as that second parameter its specification. | |
instance[prop] = props[prop].value; | |
} | |
} | |
} | |
// Return new object | |
return instance; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment