4 ms·
And whether it mutates is kind of a surprise. Like reduce doesn't, even though it works similar to forEach, map, and every.
by konsumer 8y ago
And whether it mutates is kind of a surprise. Like reduce doesn't, even though it works similar to forEach, map, and every.
- twiss 8y agoNo, all of them do: https://codepen.io/anon/pen/bKKaBy?editors=0010 https://codepen.io/anon/pen/bKKaBy?editors=0010 All of these pass the original array as the last argument, reduce()'s callback just takes one more argument, hence the confusion in the original codepen. It would indeed be highly surprising if some of these functions passed a copy of the original array.
- konsumer 8y agoah, yeah, forgot acc param in reduce. updated.