Echo JS 0.11.0

<~>
tracker1 2625 days ago. link 2 points
No mention of reduce...

    Object.keys(obj)
      .map(k => foo(k, obj[k]))
      .reduce((a, b) => Object.assign(a, b), {});

that's one of my favorites... break up an object/hash map, do something to each, and reconstruct hash map... assuming `foo(k, v)` returns `{ [k]: bar(v) }`;

map is cool and powerful, but so is reduce.

Replies

babula 2625 days ago. link 3 points
Did you read the whole article? He mentions reduce towards the end.
tracker1 2624 days ago. link 1 point
My bad.. the data section in reduce was similar to filtering, I'd scrolled back to the top while reading, then back down, and got into filtering.