Skip to content

Instantly share code, notes, and snippets.

@ironboy
Created November 5, 2015 10:48
Show Gist options
  • Save ironboy/d968d7e9d1e6599a70b2 to your computer and use it in GitHub Desktop.
Save ironboy/d968d7e9d1e6599a70b2 to your computer and use it in GitHub Desktop.
john resigs polyfill for Object.getPrototypeOf
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