-
-
Save roboticstone/bf537252607286aa8ef6 to your computer and use it in GitHub Desktop.
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
// Object.create Partial Polyfill | |
// Support for second parameter is non-standard | |
if (typeof Object.create !== 'function') { | |
Object.create = function(o, props) { | |
// Create new object whose prototype is o | |
function F() {} | |
F.prototype = o; | |
result = 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. | |
result[prop] = props[prop].value; | |
} | |
} | |
} | |
// Return new object | |
return result; | |
}; | |
} |
You're missing a var for the result and prop so you are creating global variables.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try to pass
null
as the second argument. You need to throw in that case.