3 ms·
Forget Ramda and Lodash, functional js vanilla is ezpz
- detaro 9y agoPlease use the title of the linked article in submissions
- andreareina 9y agoIn case anyone else got confused by the `.forEach(...)` clause, it's turning the Array methods into functions that partially apply the non-this parameters. e.g: map = fn => array => array.map(fn) This construction requires the included `pipe` and `compose` functions to ergonomic (otherwise you're stuck writing `map(fn)(someArray)`), though in the case of the former I don't see the benefit: pipe( filter(...), map(...), reduce(...) )(someArray) isn't any easier to type or understand than: someArray .filter(...) .map(...) .reduce(...) In fact, I would argue that the latter is clearer, and not simply due to familiarity. I'm a functional programming advocate, and I'm perfectly happy to use method chaining in the absence of pipeline operators like F#'s `|>`. Still, it's an interesting approach that I'm glad to have seen. The README also introduced me to a new bit of markup (<details>) so I'm doubly glad.