Fidel Seehawer
Sep 10, 2024

--

I'm curious why you chose this example to demonstrate the pipeline operator:

const result = [1, 2, 3]
|> (x => x.map(n => n * 2))
|> (x => x.filter(n => n > 3))
|> (x => x.reduce((sum, n) => sum + n, 0));

when the following code seems more readable:

[1, 2, 3]
.map((n) => n * 2)
.filter((n) => n > 3)
.reduce((sum, n) => sum + n, 0)

Could you explain the benefit of using the pipeline operator in this case?

--

--

Fidel Seehawer
Fidel Seehawer

Written by Fidel Seehawer

A father, husband, and software developer from the lovely city of Düsseldorf. With a passion for technology and a strong drive to constantly learn.

Responses (2)