JS Built-ins
ObjectObject.fromEntriesbeginner

Object.fromEntries() β€” empty iterable

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

Use Object.fromEntries() to convert an iterable of [key, value] pairs into a plain object.

Object.fromEntries() with empty input

Passing an empty array (or empty iterable) to Object.fromEntries returns an empty object {}.

Challenge: Implement emptyFromEntries() that calls Object.fromEntries([]) and returns the result.

emptyFromEntries() // β†’ {}
πŸ’‘ Hints (1)
  • β€’ `Object.fromEntries([])` is valid and returns `{}`.