emilioriosvz
3/14/2016 - 10:12 PM

Get all properties names of an object

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
}