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?