Node.js provides us with an interactive code execution known as REPL (Read-Eval-Print-Loop) where you can execute and run code on the shell.
- Read: Read user's inputs, and parses it into a data structure in memory.
- Eval: Takes this internal data structure and evaluates it.
- Print: taking the result yielded by eval, and prints it out to the user.
- Loop: repeat the steps above.
To do so open your shell or cmd and type: node.
> node Welcome to Node.js vX.Y.Z. Type ".help" for more information.
Hello world with REPL
> console.log("hello world") hello world > 4+4 8 > [1,2,3].reduce((u,v)=>u+v,0) 6 > var x = "hello" > let y = "world" > let hello = x + " " + y > console.log(hello) hello world
To quit the REPL type "ctrl+c" twice.