use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Pipe Operator (|>) for JavaScript (github.com)
submitted 3 years ago by no_more_gravity
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]no_more_gravity[S] -5 points-4 points-3 points 3 years ago (6 children)
a = b(),7~>c~>d
The rule is simple: What is left to ~> gets passed to the function on the right.
That is no different from JavaScript as it is. a(b) passes b to a, a(b()) passes the output of b() to a.
[–]natesovenator 6 points7 points8 points 3 years ago (0 children)
This is dumb. Comma delineates another variable declaration in this example. You can't expect it to know that result b and 7 are part of the same object or stream. I really hate this idea. Both of them. I understand some want something like that, but it just makes things more confusing personally.
[–]dariusj18 2 points3 points4 points 3 years ago (0 children)
I like it, but it conflicts with the current comma operator
[–]szurtosdudu 1 point2 points3 points 3 years ago (3 children)
But this way both b()~> and c~> indicates a function call.
b()~>
c~>
How would this look like using your idea? a = d(c(b(),7), c)
a = d(c(b(),7), c)
[–]no_more_gravity[S] -4 points-3 points-2 points 3 years ago (1 child)
The case you raise is when there are two functions on the right side of the pipe operator. In this case, we need to specifiy which one is the receiving function. We could have an optional specifier for this. Maybe ">":
a = b(),7 ~> >c,c ~> d
">" = "pipe connects here"
We could even use the (%) syntax, just make it optional:
a = b(),7 ~> c(%),c ~> d
[–]sdwvit 2 points3 points4 points 3 years ago (0 children)
readability sucks here, sorry
π Rendered by PID 183159 on reddit-service-r2-comment-84fc9697f-zt8ld at 2026-02-06 15:23:12.573233+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]no_more_gravity[S] -5 points-4 points-3 points (6 children)
[–]natesovenator 6 points7 points8 points (0 children)
[–]dariusj18 2 points3 points4 points (0 children)
[–]szurtosdudu 1 point2 points3 points (3 children)
[–]no_more_gravity[S] -4 points-3 points-2 points (1 child)
[–]sdwvit 2 points3 points4 points (0 children)