Created
August 16, 2019 11:22
-
-
Save mshavliuk/9f8dbd225b5271f51e4d34e485946fe4 to your computer and use it in GitHub Desktop.
getMethods js function
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
const getMethods = (obj) => { | |
let properties = new Set() | |
let currentObj = obj | |
do { | |
Object.getOwnPropertyNames(currentObj).map(item => properties.add(item)) | |
} while ((currentObj = Object.getPrototypeOf(currentObj))) | |
return [...properties.keys()].filter(item => typeof obj[item] === 'function') | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment