Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Node.js Tutorial
Parts of Node.js
Features of Node.js
Install Node.js Windows
Install Node.js Linux
Node.js First Example
Node.js Console
Node.js JavaScript Learn
Node.js REPL
Node.js NPM
Node.js CL Options1
Node.js CL Option2
Node.js Globals
Node.js OS
Node.js Timer
Node.js Errors
Node.js DNS
Node.js Net
Node.js Crypto
Node.js TLS/SSL
Node.js Debugger
Node.js Process
Node.js Process Example
Node.js Process Example2
Node.js Child Process
Child Process EXEC
Child Process SPAWN
Child Process Fork
Node.js Buffers
Node.js Streams
Node.js Reading Stream
Node.js Writing Stream
Node.js Piping Stream
Node.js Chaining Streams
Node.js File System Part1
Node.js File System Part2
Node.js File System Part3
Node.js Path
Node.js StringDecoder
Node.js Query String
Node.js ZLIB
Node.js Assertion
Node.js V8
Node.js Callbacks
Node.js Events
Node.js Punycode
Node.js TTY
Node.js Web Module
Node.js Upload Files
Node.js Email Send
Node.js BuiltIn Modules
Node.js Assert Code
Node.js Assert Function
Node.js console.time()
Node.js console.table()
Node.js DNS Code
Node.js cipher.final()
Node.js URL.hash API
Node.js URL.host API
Node.js URL.origin API
Node.js MySQL
Folders in Node.js
Folders Node.js part3
Rename Folder Node.js
Remove Folder Node.js
 


  

 
Node.js REPL
Question Posted on 28 Jan 2024

Home >> Tutorial >> Node.js Tutorial >> Node.js REPL


Node.js REPL

Node.js REPL



Well the term REPL mainly stand for "Read Eval Print and Loop". And this will specifies a computer environment like a window console or a Unix/Linux shell where we can enter the commands. And once we input the commands system will responds an output in an interactive mode.


REPL Environment



Node.js or node will come in bundled with REPL environment. And each part of the REPL environment has a specific work.

Read:This will reads users input; and parse the input into JavaScript data-structure and stores in memory.

Eval:This will takes and evaluates the data structure.

Print:This will print the result.

Loop:This will loops the above command until user will press ctrl-c twice.


How to start REPL



And to start REPL by simply running "node" on the command prompt as given below:-



REPL Start

And you can execute various mathematical operations on REPL Node.js command prompt.


Node.js Simple Expressions



Once you start REPL node command prompt you can put any mathematical expression:-

Example:>10+20-5
25




REPL Math Calc

Example2:>10+20+(4*5)/7




REPL Math Calc


Using variable



Well variables are used to store values and print later. If you do not use "var" keyword then value is stored in the variable and printed and on another hand if "var" keyword is used then value is stored but not printed. And you can print variable by using console.log().



REPL Math Mix


Node.js Multiline expressions



Node REPL also support multiline expressions like JavaScript. Below multiline code have the do-while loop example:-


var x = 0
undefined
> do {
...x++;
...console/log("x:" + x);
...} while ( x< 10);




REPL Math Loop


Node.js Underscore Variable



Well we use _ underscore to get the last result. Below example will helps you understand the _.



REPL Math Underscore


Node.js Exit REPL



to exit in REPL you need to use ctrl+c command twice to come out of Node.js.



REPL Exit


Node.js REPL Commands



Below are some important REPL commands used in REPL.


CommandsDescription
ctrl + cIt is used to terminate the current command.
ctrl + c twiceIt terminates the node repl.
ctrl + dIt terminates the node repl.
up/down keysIt is used to see command history and modify previous commands.
tab keysIt specifies the list of current command.
.helpIt specifies the list of all commands.
.breakIt is used to exit from multi-line expressions.
.clearIt is used to exit from multi-line expressions.
.save filenameIt saves current node repl session to a file.
.load filenameIt is used to load file content in current node repl session.



Other Important Questions
Parts of Node.js
Install Node.js Linux
Node.js First Example
Node.js Globals
Node.js DNS







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |