JS Built-ins
ObjectObject.entriesbeginner

Object.entries() β€” order matches Object.keys

πŸ“– Usage Example
// Get [key, value] pairs of an object
const obj = { a: 1, b: 2 }
Object.entries(obj)   // β†’ [['a', 1], ['b', 2]]

Use Object.entries() to get an array of [key, value] pairs for iterating over an object's own enumerable properties.

Object.entries() β€” consistent ordering

The order of entries from Object.entries matches the order of keys from Object.keys. Both follow insertion order for string keys.

Challenge: Implement entryKeys(obj) that returns just the keys from Object.entries (the first element of each pair).

entryKeys({ b: 2, a: 1 }) // β†’ ['b', 'a']
πŸ’‘ Hints (1)
  • β€’ Destructure each entry as `([k])` to grab just the key.