Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get all properties names of an object
var getAllProperties = function (object) {
var properties = []
do {
Object.getOwnPropertyNames(object).forEach((prop) => {
if (!~properties.indexOf(prop)) {
properties.push(prop)
}
})
} while (object = Object.getPrototypeOf(object))
return properties
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment