Skip to content

Instantly share code, notes, and snippets.

@wickkidd
Created June 9, 2020 14:57
Show Gist options
  • Save wickkidd/e6b005132349ff7664e2b3af8abe9718 to your computer and use it in GitHub Desktop.
Save wickkidd/e6b005132349ff7664e2b3af8abe9718 to your computer and use it in GitHub Desktop.
js get object properties (incl inherited)
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