Created
August 26, 2022 07:22
-
-
Save l-portet/10b25b3b034d49e739a6f05f881fce03 to your computer and use it in GitHub Desktop.
Find all properties & methods of an object, up to the root prototype
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
// Find all properties & methods of an object, up to the root prototype | |
function findAllProps(obj, props = []) { | |
if (!obj) { | |
return props; | |
} | |
return findAllProps(Object.getPrototypeOf(obj), [ | |
...props, | |
Object.getOwnPropertyNames(obj), | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment