Created
November 5, 2015 10:48
-
-
Save ironboy/d968d7e9d1e6599a70b2 to your computer and use it in GitHub Desktop.
john resigs polyfill for Object.getPrototypeOf
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.getPrototypeOf !== "function" ) { | |
if ( typeof "test".__proto__ === "object" ) { | |
Object.getPrototypeOf = function(object){ | |
return object.__proto__; | |
}; | |
} else { | |
Object.getPrototypeOf = function(object){ | |
// May break if the constructor has been tampered with | |
return object.constructor.prototype; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment