Skip to content

Instantly share code, notes, and snippets.

@l-portet
Created August 26, 2022 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l-portet/10b25b3b034d49e739a6f05f881fce03 to your computer and use it in GitHub Desktop.
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
// 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