JS Built-ins
ObjectObject.keysbeginner

Object.keys() β€” inherited properties excluded

πŸ“– Usage Example
// Get array of own enumerable property names
const obj = { a: 1, b: 2, c: 3 }
Object.keys(obj)   // β†’ ['a', 'b', 'c']

Use Object.keys() to get an array of an object's own enumerable property names for iteration or counting.

Object.keys() β€” own properties only

Unlike for...in, Object.keys() does not include inherited properties from the prototype chain.

Challenge: Use Object.keys() to get only the own keys of an object that inherits from another.

πŸ’‘ Hints (1)
  • β€’ Object.keys ignores the prototype chain