JavaScript:
Using an interactive shell (REPL)

How to:

Node.js ships with a REPL accessible via the terminal. Pop it open, and you’re ready to roll. Here’s a taste:

$ node
> let sum = (a, b) => a + b;
undefined
> sum(5, 10);
15
> .exit

Straightforward, right? Define variables, functions, or run loops. When done, .exit takes you back to the real world.

Deep Dive

REPLs have been around since the 1960s – LISP pioneered the concept. The idea: give immediate feedback to the programmer. Alternatives? Besides Node.js REPL, there’s browser-based consoles like Chrome DevTools, online sandboxes like JSFiddle, or full IDEs like VSCode with interactive playgrounds.

Under the hood, REPL workflows typically:

  1. Read input
  2. Compile and execute code
  3. Print output
  4. Loop back

It’s a simple yet effective cycle that has massively influenced interactive coding.

See Also