Skip to content

Instantly share code, notes, and snippets.

@mshavliuk
Created August 16, 2019 11:22
Show Gist options
  • Save mshavliuk/9f8dbd225b5271f51e4d34e485946fe4 to your computer and use it in GitHub Desktop.
Save mshavliuk/9f8dbd225b5271f51e4d34e485946fe4 to your computer and use it in GitHub Desktop.
getMethods js function
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