Created
July 24, 2009 16:32
-
-
Save eligrey/154398 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
if (!Object.getPrototypeOf) { | |
if (typeof this.__proto__ === "object") | |
Object.getPrototypeOf = function (obj) { | |
return obj.__proto__; | |
}; | |
else { | |
Object.getPrototypeOf = function (obj) { | |
var constructor = obj.constructor, | |
oldConstructor; | |
if (Object.prototype.hasOwnProperty.call(obj, "constructor")) { | |
oldConstructor = constructor; | |
if (!(delete obj.constructor)) // reset constructor | |
return null; // can't delete obj.constructor, return null | |
constructor = obj.constructor; // get real constructor | |
obj.constructor = oldConstructor; // restore constructor | |
} | |
return constructor ? constructor.prototype : null; // needed for IE | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment