Created
March 28, 2018 13:04
-
-
Save emmiep/a06fdc8d2d2be163cee455413f1e1d4a to your computer and use it in GitHub Desktop.
Get all function names (including inherited)
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
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