0% found this document useful (0 votes)
23 views

How Node - Js Works

Node.js is a JavaScript runtime environment that allows JavaScript to be run on the server-side. It uses the V8 engine and a single-threaded event loop model to handle non-blocking I/O operations asynchronously. This event-driven architecture and its ability to handle many concurrent connections efficiently make Node.js ideal for building scalable network applications like web servers. Node.js also has a package manager (npm), supports modules, and includes many built-in modules for common system tasks.

Uploaded by

amir majidinia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

How Node - Js Works

Node.js is a JavaScript runtime environment that allows JavaScript to be run on the server-side. It uses the V8 engine and a single-threaded event loop model to handle non-blocking I/O operations asynchronously. This event-driven architecture and its ability to handle many concurrent connections efficiently make Node.js ideal for building scalable network applications like web servers. Node.js also has a package manager (npm), supports modules, and includes many built-in modules for common system tasks.

Uploaded by

amir majidinia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

CodeWithAnjum

@codewithanjum
01

HOW
NODE.JS
WORKS

Follow On IG Subscribe On YT
@codewithanjum @codewithanjum
CodeWithAnjum
@codewithanjum
02

Node.js is an open-source, cross-platform


JavaScript runtime that enables server-side
execution of JavaScript code outside of a web
browser.

It's built on the V8 engine, used in


Google Chrome, and designed for asynchronous,
event-driven development, ideal for scalable and
high-performance applications.

Here's how Node.js works:

Follow On IG Subscribe On YT
@codewithanjum @codewithanjum
CodeWithAnjum
@codewithanjum
03

V8 Engine:
Node.js uses the V8 engine to interpret and
execute JavaScript code.
V8 compiles JavaScript code into machine code,
optimizing its performance.

Single-Threaded Event Loop:


Node.js operates on a single-threaded event loop,
which means it processes tasks one by one in a
non-blocking manner. This single-threaded nature
allows Node.js to handle concurrent connections
efficiently.

Follow On IG Subscribe On YT
@codewithanjum @codewithanjum
CodeWithAnjum
@codewithanjum
04

Non-Blocking I/O:
One of the key features of Node.js is its
non-blocking I/O model. When Node.js performs
an I/O operation (e.g., reading from a file,
making an HTTP request, or querying a database),
it doesn't block the execution of other code.
Instead, it registers a callback function and
continues processing other tasks. Once the I/O
operation is complete, the callback is triggered,
and the result is handled.

Follow On IG Subscribe On YT
@codewithanjum @codewithanjum
CodeWithAnjum
@codewithanjum
05

Event-Driven Architecture:
Node.js relies heavily on events and callbacks.
Events are emitted when certain actions occur,
and callback functions are registered to handle
these events.

For example, when an HTTP request is received


by a Node.js server, it triggers an event, and a
callback function is called to handle that request.

Follow On IG Subscribe On YT
@codewithanjum @codewithanjum
CodeWithAnjum
@codewithanjum
06

npm (Node Package Manager):


npm is the package manager for Node.js, allowing
developers to easily install, manage, and share
third-party libraries (packages) to extend the
functionality of their applications.

Modules:
Node.js follows the CommonJS module system. It
allows developers to organize their code into
reusable modules, each encapsulating specific
functionality. Modules can be imported into other
modules using the require() function.

Follow On IG Subscribe On YT
@codewithanjum @codewithanjum
CodeWithAnjum
@codewithanjum
07

Built-in Modules:
Node.js comes with a set of built-in modules
that provide core functionality, such as fs for file
system operations, http for creating HTTP servers,
path for handling file paths, and more.

Libuv:
Node.js uses the Libuv library to handle
asynchronous I/O operations and abstract the
underlying operating system's I/O capabilities.

Follow On IG Subscribe On YT
@codewithanjum @codewithanjum
CodeWithAnjum
@codewithanjum
08

Server-Side Web Development:


With Node.js, developers can build server-side
applications like web servers and APIs, handling
incoming requests and providing responses.
Popular web frameworks like Express.js are often
used to simplify the process of building web
applications with Node.js.

Scalability:
Node.js is known for its ability to handle a large
number of concurrent connections efficiently due
to its non-blocking, event-driven nature.

Follow On IG Subscribe On YT
@codewithanjum @codewithanjum
CodeWithAnjum
09
@codewithanjum

Did you Find this


Post a bit Useful?
Tap on like button, Share with your friends & save for Later.

Follow On IG Subscribe On YT
@codewithanjum @codewithanjum

You might also like