Published at
Updated at
Reading time
This post is part of my Today I learned series in which I share all my web development learnings.

In July 2017 I wrote about ways to execute JavaScript snippets from your clipboard using process substitution. The snippet that I'm using since then to execute JavaScript snippets quickly is the following...

$ node <(pbpaste)

Today I came across a tweet by Julian Gruber and it turns out you use the pipe operator with the Node.js binary directly.

$ pbpaste | node

The result is the same but it looks nicer and feels better that using process substituion (<(...)). I have no idea how I missed this Node.js detail and checked the previous versions of Node.js and it works going down to Node.js v4 (that's what I have available on my machine). Good to know!

Was this TIL post helpful?
Yes? Cool! You might want to check out Web Weekly for more quick learnings. The last edition went out 3 days ago.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles