The Node REPL
The Node REPL is an interactive prompt for JavaScript. REPL is short for Read Eval Print Loop.
A sum
Type this line at the prompt. The REPL prints the answer.
2 + 3A length
This line asks for the length of the word Node.
"Node".lengthExample
2 + 3
"Hello, Node!"
"Node".length
.exitKey points
- Type node on its own to open the REPL.
- Interactive means you type and it answers at once.
- The REPL shows a > prompt and waits for a line.
- REPL reads the line, runs it, and prints the answer.
- A prompt is a mark that waits for typed input.
- Type .exit to leave the REPL.
In this example, the REPL first prints two welcome lines. The first typed line asks for the sum of 2 and 3. The REPL prints 5. The second typed line gives a greeting in quotes. The REPL prints it back with single quotes. The third typed line asks for the length of Node. The REPL prints 4. The last typed line leaves the REPL.
Note
The REPL keeps no file, so nothing is saved.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does the REPL do after you type a line?