REPL in Nodejs | Read-Eval-Print-Loop in Node

 


==>Node.js comes with a virtual environment called REPL (aka Node shell). Node REPL stands for Read-Eval-Print-Loop. It is a quick and easy way to test simple Node.js/JavaScript code.

==>The following table lists important REPL commands.

REPL Command

Description

.help

Display help on all the commands

tab Keys

Display the list of all commands.

Up/Down Keys

See previous commands applied in REPL.

.save filename

Save current Node REPL session to a file.

.load filename

Load the specified file in the current Node REPL session.

ctrl + c

Terminate the current command.

ctrl + c (twice)

Exit from the REPL.

ctrl + d

Exit from the REPL.

.break

Exit from multiline expression.

.clear

Exit from multiline expression.



Async/await:- 

=> Async/await is a new way to write asynchronous code. Previous options for asynchronous code are callbacks and promises.

=> Async/await is actually built on top of promises. It cannot be used with plain callbacks or node callbacks.

=> Async/await is, like promises, nonblocking.

=> Async/await makes asynchronous code look and behave a little more like synchronous code. This is where all its power lies.