REPL is one of the most powerful features of Node.js for beginners and developers. It allows you to run JavaScript code instantly without creating a file.
REPL stands for Read – Evaluate – Print – Loop.
1. What is REPL?
REPL is an interactive shell where you can write JavaScript code and get output immediately.
- Testing code
- Debugging
- Learning JavaScript
- Quick calculations
2. How to Start REPL
Type:
node
You will see:
>
3. Simple Examples
Math
10 + 20
Output:
30
Variables
let name = "Node.js" name
Output:
Node.js
4. Multi-line Code
function add(a, b) {
return a + b;
}
add(5, 5);
5. Special Commands
- .help
- .clear
- .save file.js
- .load file.js
- .exit
6. Previous Output
5 + 5 _
REPL is great for testing, but real apps should use files.
Conclusion
Now you can test JavaScript instantly using Node.js REPL.
Your journey is getting interactive ⚡🚀
Tags
NodeJS