Node.js REPL (Read-Eval-Print Loop)
Node.js provides an interactive shell called REPL ÔÇö Read-Eval-Print Loop. It lets you execute JavaScript line by line and see results instantly ÔÇö perfect for testing, debugging, and learning.
Node.js Tutorial:-
Complete Python Course:-
How REPL Works
- Read: Reads user input and parses it into a JavaScript expression.
- Eval: Evaluates the expression.
- Print: Outputs the result.
- Loop: Repeats until exit (Ctrl+C twice).
Start the REPL
node
# > (you can now type JavaScript)
Simple Expressions
> 10 + 20 - 5
25
> "Hello " + "World"
'Hello World'
Working with Variables
> let name = "UpdateGadh"
undefined
> console.log(name)
UpdateGadh
Multi-line Expressions
> var x = 0
undefined
> do {
... x++;
... console.log("x:", x);
... } while (x < 3);
The Underscore Variable (_)
The _ variable holds the last evaluated expression:
> 5 + 10
15
> _ * 2
30
Useful REPL Commands
.helpÔÇö list all REPL commands..breakÔÇö exit a multi-line expression..clearÔÇö clear the current state..save filenameÔÇö save session to a file..load filenameÔÇö load JS into the session.Ctrl+Ctwice orCtrl+DÔÇö exit REPL.TabÔÇö autocomplete.
Download New Real Time Projects:- Click here
Complete Advance AI topics:-
Conclusion
The Node.js REPL is a simple but powerful tool for experimenting, testing snippets, and debugging. Mastering its commands speeds up your workflow. For more tutorials, stay tuned to .
node js repl online
repl in node js example
online node js compiler with npm
node js online playground
node js online editor
node repl import
node js repl command line
node js repl commands