REPL (READ, EVAL, PRINT, LOOP) is a computer environment similar to Shell (Unix/Linux) and command prompt. Node comes with the REPL environment when it is installed. System interacts with the user through outputs of commands/expressions used. It is useful in writing and debugging the codes. The work of REPL can be understood from its full form:
Print : The result is printed after the evaluation.
Loop : Loops the input command. To come out of NODE REPL, press ctrl+c twice
Getting Started with REPL:
To start working with REPL environment of NODE; open up the terminal (in case of UNIX/LINUX) or the Command prompt (in case of Windows) and write node and press ‘enter’ to start the REPL.
The REPL has started and is demarcated by the ‘>’ symbol. Various operations can be performed on the REPL. Below are some of the examples to get familiar with the REPL environment.
Example: Performing Arithmetical operations in REPL
Example: Performing operations using libraries of NODE. MATH library is being used in below example.
Note: using ‘math’ shows error as the library is referenced as ‘Math’ in NODE and not ‘math’.
Example: Using variables in REPL. The keyword var is used to assign values to variables.
Example: Using loops in REPL. Loops can be used in REPL as in other editors.
Note: Use ctrl – c to terminate the command and ctrl – c twice to terminate the NODE REPL.
.help is used to list out all the commands.
- Nodejs | Automatic restart NodeJs server with nodemon
- Print Number series without using any loop
- PHP | eval() Function
- eval command in Linux with Examples
- Nodejs | DNS
- Web-Socket in NodeJS
- Introduction to NodeJS
- Nodejs | DNS | setServers()
- Encrypting Data in NodeJS
- Difference between NodeJS and AngularJS
- Nodejs | Web Crawling using Cheerio
- Dockerizing a simple Nodejs app
- Nodejs – Connect Mysql with Node app
- Signup Form Using Nodejs and MongoDB
- Cowsay in Nodejs using Requests library
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.