A brief view on Understanding Node.Js

Madhusudan Bhardwaj
AltCampus
Published in
2 min readDec 22, 2018

What is Node exactly?

Node is a javascript server-side Javascript Run-time environment build using Javascript V8 engine implemented in C++ .

Node js is presented as two parts:

  1. Script processor.
  2. REPL.

1.Script Processor

Script processor is invoked by calling node in the command line and it executes the program.

But it’s not directly passed to V8 first it initializes an Event Loop and process parts of your javascript file and keeps on checking until there is no part is left to be executed.

How this looks:

  1. Reads the file you specified.
  2. Reads all the dependencies that file specifies.
  3. Begin executing Synchronous tasks in those files and asynchronous tasks(event loop is what allows Node.js to perform non-blocking I/O operations).
  4. Begin processing the list until there is nothing left to process by the event loop.

2.REPL

R- READ
E-EVAL
P-PRINT
L-LOOP

The repl works like a console within a web browser
when you enter a node command within the terminal and don’t type the file name to execute with the node it executes node will start the REPL.
Will show a cursor that REPL has started the R -READ phase i.e. reading input from you and event loop will start and sit and wait for your input when entered it will enter E -EVAL phase executing the task.
when the event loop is done with it, it enters P -PRINT phase and after that, it reads backs to the entering L -LOOP phase and repeats that process again until the last task.

Anatomy of Node app

We created a simple server in node.

--

--