list all properties of object javascript code example

Example 1: js select keys from object

const object = { a: 5, b: 6, c: 7  };
const picked = (({ a, c }) => ({ a, c }))(object);

console.log(picked); // { a: 5, c: 7 }

Example 2: javascript list object properties

var person={"first_name":"Bill","last_name":"Jenner"}
//get the person object properties with:
var keys = Object.keys(person); //keys = ["first_name","last_name"]

Example 3: javascript list class properties

function getClassProperties(instanceOfClass) {
  const proto = Object.getPrototypeOf(instanceOfClass);
  const names = Object.getOwnPropertyNames(proto);
  return names.filter(name => name != 'constructor');
}