DEV Community

Discussion on: Learn To Fold Your JS Arrays

Collapse
 
jasonsbarr profile image
Jason Barr

The whole way down the post I was asking myself "why not just use Array.reduce() and then you mentioned it at the end. 😂

Succinct explanation though, and since AFAIK no widely used JavaScript engine implements tail call optimization it's likely that having a base folding function that uses a for loop instead of recursion will be necessary for data sets of a certain size.

Well done, though.