Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Forget Ramda and Lodash, functional js vanilla is ezpz (medium.com/docodemore)
2 points by tonechild on Nov 7, 2017 | hide | past | favorite | 2 comments


In 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.


Please use the title of the linked article in submissions




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: