InterviewSolution
| 1. |
What is REPL in Node.js? |
|
Answer» REPL module in Node.js is Read-Eval-Print-Loop (REPL) implementation. It’s just like a SHELL and command prompt.REPL is available both as a standalone program or included in other applications. It can be accessed using the command: “const repl = REQUIRE('repl');” REPL accept individual lines of user input, evaluate them and then output the result. Input and output use stdin and stdout, respectively, or use any Node.js stream.REPL is mainly used for testing, debugging, or experimenting as it helps to execute ad-hoc javascript statements. The repl module exports the “repl.REPLServer” class which supports automatic completion of multi-line inputs, Emacs-style line editing, ANSI-styled output, saving and RESTORING current REPL session state, error recovery, and customizable evaluation functions. REPL environment could be started by the opening terminal in case of Unix/Linux or command prompt in case of windows and typing “node”. Some of the commands supported by the REPL environment are below:
|
|