Loading problem…
Implement a keyBy function that creates an object composed of keys generated from the results of running each element through an iteratee.
keyBy([{ id: 'a', name: 'Alice' }, { id: 'b', name: 'Bob' }], 'id');
// Returns: { a: { id: 'a', name: 'Alice' }, b: { id: 'b', name: 'Bob' } }
keyBy([1.2, 2.4, 3.6], Math.floor);
// Returns: { 1: 1.2, 2: 2.4, 3: 3.6 }This is commonly used to normalize API responses for efficient lookup by ID, especially in Redux/state management.