Hacker News new | ask | show | jobs
by konsumer 2915 days ago
And whether it mutates is kind of a surprise. Like reduce doesn't, even though it works similar to forEach, map, and every.
1 comments

No, all of them do: 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.

ah, yeah, forgot acc param in reduce. updated.