Tuesday, 12 November 2019

Introduction to Node.js

As we have seen in the JavaScript's post, we have discussed that it can be executed in any browsers.
Node.js is a JavaScript runtime environment that executes the JavaScript code outside of browsers. Node.js let's developers use JavaScript to code backend, serverside to produce dynamic websites.
There are many top companies use node.js. GoDaddy, LinkedIn, IBM, eBay, PayPal and many more prefer node.js.
Node.js is well known for real time applications. Like chat applicatins, streaming servers, games and much more. 

Over the years, most of the applications were based on a stateless request-response framework. In these sort of applications, it is up to the developer to ensure the right code was put in place to ensure the state of web session was maintained while the user was working with the system.
But with Node.js web applications, you can now work in real-time and have a 2-way communication. The state is maintained, and either the client or server can start the communication.
( Thank you guru99.com)

Ya. In my words I could say node.js works like full duplex communication system.

Frequently asked questions about node.js.(from w3 schools)
What is Node.js?
Node.js is an open source server environment
Node.js is free
Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
Node.js uses JavaScript on the server
Why Node.js?
Node.js uses asynchronous programming!

A common task for a web server can be to open a file on the server and return the content to the client.

Here is how PHP or ASP handles a file request:

Sends the task to the computer's file system.
Waits while the file system opens and reads the file.
Returns the content to the client.
Ready to handle the next request.
Here is how Node.js handles a file request:

Sends the task to the computer's file system.
Ready to handle the next request.
When the file system has opened and read the file, the server returns the content to the client.
Node.js eliminates the waiting, and simply continues with the next request.

Node.js runs single-threaded, non-blocking, asynchronously programming, which is very memory efficient.

What Can Node.js Do?
Node.js can generate dynamic page content
Node.js can create, open, read, write, delete, and close files on the server
Node.js can collect form data
Node.js can add, delete, modify data in your database
What is a Node.js File?
Node.js files contain tasks that will be executed on certain events
A typical event is someone trying to access a port on the server
Node.js files must be initiated on the server before having any effect
Node.js files have extension ".js"

1 comment: