Created
February 6, 2016 23:01
-
-
Save molily/80bb979b5e69f727f068 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
# Returns the prototype chain of an object. | |
# In old browsers, falls back to the __super__ property | |
# set up by CoffeeScript classes. | |
# Returns an array. | |
getPrototypeChain = do -> | |
if Object.getPrototypeOf | |
(object) -> | |
chain = [] | |
while object = Object.getPrototypeOf(object) | |
chain.push object | |
chain | |
else | |
(object) -> | |
chain = [object.constructor.prototype] | |
while object = object.constructor?.__super__ | |
chain.push object | |
chain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment