Skip to content

Instantly share code, notes, and snippets.

@emmiep
Created March 28, 2018 13:04
Show Gist options
  • Save emmiep/a06fdc8d2d2be163cee455413f1e1d4a to your computer and use it in GitHub Desktop.
Save emmiep/a06fdc8d2d2be163cee455413f1e1d4a to your computer and use it in GitHub Desktop.
Get all function names (including inherited)
function getFunctionNames(object) {
const keys = Object.getOwnPropertyNames(object);
const names = keys.filter((name) => object[name] instanceof Function);
const prototype = Object.getPrototypeOf(object);
return names.concat(prototype && getFunctionNames(prototype) || []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment