Open In App
Related Articles


Improve Article
Save Article
Like Article

Node.js is an open source server-side Javascript run-time environment built on Chrome’s JavaScript Engine(V8). Node.js is used for building fast and scalable applications and is an event driven, non-blocking I/O model.

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:

Read : It reads the inputs from users and parses it into JavaScript data structure. It is then stored to memory.
Eval : The parsed JavaScript data structure is evaluated for the results.
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.

open node repl gfg

open node 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

simple math arithmetic gfg

Arithmetical operations in REPL

Example: Performing operations using libraries of NODE. MATH library is being used in below example.

Math library methods gfg

Math library methods gfg

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.

variable assignment gfg

Using Variables in REPL

Example: Using loops in REPL. Loops can be used in REPL as in other editors.
multiline expression gfg

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.

repl help gfg

Using .help in REPL

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 29 Apr, 2018
Like Article
Save Article
Similar Reads
Complete Tutorials