Object.keys()
Returns an array of an object's own enumerable property names, in the same order Object.entries() and for...in would visit them.
const user = { name: 'Ada', age: 30 };
Object.keys(user); // ['name', 'age']
Object.keys(user).length; // 2 — common way to count properties
- Only own properties — inherited/prototype properties are excluded
- Pairs naturally with .map()/.forEach() to iterate an object's keys
- Object.values() and Object.entries() are the companion methods for values and [key,value] pairs