How I run little JavaScript snippets
By Flavio Copes
The tools I use to run little JavaScript snippets while testing ideas: the browser DevTools, the Quokka.js VS Code extension, and the RunJS desktop app.
As I learn and try new different things using Javascript, I run little snippets of JavaScript every day.
Browser DevTools
Sometimes I just open a Chrome or Firefox DevTools window and type things there. This is perfect to try out a line or two, especially when you need the DOM, fetch, or anything else that only exists in the page.
It becomes a little of a problem if you have to spend some time on the code. There is no file to save, and a page reload wipes out everything you defined. (Redeclaring a const used to throw an error in the console too, but Chrome has allowed that since version 92, in 2021.)
Quokka.js
There is a nice VS Code extension called Quokka.js. It’s a great way to test JS snippets while working in your editor: it shows the value of each line inline, next to the code, as you type, so you never leave the file you are working on.
RunJS
Another tool I use is RunJS, a little Electron application. When I wrote this post it was macOS-only. Today it runs on macOS, Windows and Linux, and it is a paid app with a license.

You can type code on the left, and the app shows the result on the right.
The code evaluates as you type, so you don’t have to press “run” or have roadblocks while you try things out.
It can test both browser and Node.js code.
You can import Node modules just by setting a working directory (from the “Actions” menu) where it can find them in a node_modules folder. Or you can just install npm packages from the “Tools > NPM Packages” window.
It supports TypeScript, and JSX and TSX too.
I use RunJS as a scratchpad for the longer experiments, especially Node code that needs an npm package.
Node REPL
If you already have Node installed, open a terminal and run:
node
That starts the Node REPL, with nothing else to install. It’s good enough for server-side snippets and for quick checks on arrays or strings.
Want me to talk about your product? You can sponsor this site.
Related posts about js: