Node.js Console



Node.js Console:

To write a stream, Node.js supports three console methods:

●     Node.js console.log():

Used to display simple message on console.

Syntax:

console.log(message);

●     Node.js console.error():

Used to render error message on console.

Syntax:

console.error ( new Error (message));

  • js console.warn():

Used to display warning message on console.

Syntax:

console.warn(message);

Node.js REPL:

REPL abbreviates for Read Eval Print and Loop which means reading user input, evaluating the data, printing the result and looping the command. In Node.js, REPL specifies a console or a shell that responds in an interactive mode.

●     Starting REPL in Windows:

Run “node” on the Windows command prompt.

●     Starting REPL in Linux:

Run “nodejs” on the Linux Terminal.

●     Exit REPL:

Press ctrl + c twice.

Writing javascript code in a REPL interactive shell is useful for immediate testing of code with no stress of writing and saving the code in a file. However, this method is suitable only for testing purpose and for small codes.

Node.js REPL Commands:

Some of the important REPL commands are listed below:

 

COMMANDS USES
ctrl + c To terminate the current command.
ctrl + c twice To terminate the node REPL.
ctrl + d To terminate the node REPL.
up/down keys To see command history and modify previous commands.
 tab keys To specify the list of current command.
.help  To specify the list of all commands.
.break To exit from multi-line expressions.
.clear To exit from multi-line expressions.
.save filename To save current node REPL session to a file.
.load filename To load file content in current node REPL session.

 

Example: Example of Node.js console.log()

 console.log(‘Hello Tech Tutorialz!’);

 

OUTPUT:

 Hello Tech Tutorialz!

Tags: , , ,
Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!

https://bridgejunks.com/ https://crownmakesense.com/ https://brithaniabookjudges.com/ https://hughesroyality.com/ https://rhythmholic.com/ https://bandar89.simnasfikpunhas.com/ https://www.100calshop.co.il/products/thailand/ https://myasociados.com/ https://solyser.com/ http://konfidence.cz/ https://muscadinepdx.com/ https://bandar89.parajesandinos.com.ve/ https://goremekoop.com/ https://oncoswisscenter.com/ https://www.turunclifehotel.com/bandar89/ https://www.houseofproducts.biz/ https://taimoormphotography.com/
BIJI18 BIJI18 BIJI18