When writing experiences which use native browser methods instead of jQuery, it's very helpful to convert the NodeLists etc. to arrays so that you can then make use of Array.prototype.map and Array.prototype.filter for example. This is preferable over using the slapdash _.map and _.filter as they chain much more readably (and they are available in all browsers supported by experiences these days).
Therefore it would be nice to have a _.toArray(arrayLike) method in slapdash which converts array-like objects with a length property and indexes into a plain array. This method could fall back to Array.from when it's available.
When writing experiences which use native browser methods instead of jQuery, it's very helpful to convert the
NodeList
s etc. to arrays so that you can then make use ofArray.prototype.map
andArray.prototype.filter
for example. This is preferable over using the slapdash_.map
and_.filter
as they chain much more readably (and they are available in all browsers supported by experiences these days).Therefore it would be nice to have a
_.toArray(arrayLike)
method in slapdash which converts array-like objects with alength
property and indexes into a plain array. This method could fall back toArray.from
when it's available.Before:
After:
An alternative solution to the chaining/readability problem might be to add something like lodash's
flow
: https://lodash.com/docs/#flow