Re:Pipe Operator (|>) For JavaScript
by substation13 on Friday January 20, 2023 @11:03AM
(#34454943)
You do for member access, e.g.
let firstName =
person
|> fun x -> x.FirstName
|> trim
Some languages allow: let firstName =
person
|> .FirstName
|> trim
But you're right, expression-orientation and currying make this much more natural.
On the other hand, it works well in F# (and the ML that then borrowed it from F#) because itβs just a standard infix operator there and everything is already curried which is definitely not the case with JS. It means you will nearly always have to use a lambda when piping in JS which is honestly a bit tedious.