News for hackers. Stuff that matters.
Re:FP techniques that will help you write better JavaScript by yakshaving_jgt on Friday February 11, 2022 @09:38AM (#30301964)
Then why not just use a fold?
Re:FP techniques that will help you write better JavaScript by wlamartin on Friday February 11, 2022 @10:09AM (#30302287)
Sure, there's many ways to skin a cat. Given the option, I wouldn't choose either of these, and instead use something like filterMap[1] which I think conveys intent better than a fold or flatMap.

Btw, I'm assuming that the original map questioner wasn't solely using flatMap for side-effectful iteration, which reading again, I'm a bit suspicious about.

1: https://gcanti.github.io/fp-ts/modules/Array.ts.html#filterm...