On 2017-08-05 20:18, Naveen Chawla wrote:
I've often needed to cache array elements by a unique key each element has,
for quick access.

This is a shortcut:

```javascript
const elementsById = elements.toObjectByProperty(element=>element.id);
```

That looks like what Array.prototype.map can already do.

--
Lachlan Hunt
https://lachy.id.au/
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to