NodeJS is a single-threaded highly scalable, and event-driven no-blocking library built on the v8 javascript engine.

It’s an open-source much-acclaimed project (Github stars as of writing: 68 K). Naturally, the question may arise why this so popular in the developer community. Although the answers lie in the first paragraph the beauty of nodejs is Javascript, for developers, it means “Everything is Javascript”.

Let’s take a look at the most interesting concepts NodeJS brought to the table

Single-Threaded: Let’s take a common code to understand this better




Typically the program executes sequentially here i.e.

  1. first, it will printout Hello
  2. then it will wait for the function to return a string and print it
  3. It will print Abc

However, with Nodejs and javascript, this may result in different output

  1. first, it will print Hello
  2. then, it will print Abc
  3. it will print string returned by the function

Quite odd isn’t it. At first, it feels so, however that is what the natural way of handling async execution of the program, Your main thread should not wait for inputs from other function, and it will continue its execution.

Does it mean that the second line will not be called? The answer is no provided you have handled callbacks. Consider callbacks are returned pointers from function to main thread. This can be achieved in various ways like setTimeOut, promises, etc..

Highly Scalable: Scalability is the ability by which the app can handle more users/customers of your application. Having said that its of-course dependant upon underlying hardware. Typically we have 2 types of scalability available

  1. Vertical scalability, where the application is hosted on a single machine and processing power of the machine can be increased by upgrading processors, RAM, Memory, etc. This approach will give a boost up your app to a certain level.
  2. Horizontal scalability, where the application is hosted on multiple machines connected through the load balancer, the load balancer will analyze the traffic and send the request to the least occupied machine or in round-robin fashion again based on configuration. This is the perfect scenario for handling loads of traffic, however, it comes with time and effort for e.g. setting up almost identical environments across the machines. NodeJS being a lightweight and cross-platform runtime eases out this job. Nowadays we have docker which can be effectively used for installing an app with underlying runtime on a single go.

Event-Driven: Most of the nodejs objects like requests, responses are based on event-driven architecture. In an event-driven architecture, you can define the list of things to be performed based on the occurrence/completion of an event.

NodeJs has specially designed modules for it called EventEmitter. EventEmitter facilitate communication between objects. It registers/unregister listeners and emits the name of the events.

You can create your own event listener by extending the EventEmitter class as shown below

class myTimeEmitter extends EventEmitter {}

Using we can assign events for functions

class TimeEmitter extends EventEmitter{







const myTime = new TimeEmitter();

myTime.on(‘beforestart’, () => console.log(‘Before starting’);

myTime.on(‘atend’, () => console.log(‘towardsend’);

myTime.execute(() => console.log(‘executing find’));

It’s super easy to design event-based solutions for nodejs application

Well, these are the few major things nodejs provide. Apart from these NodeJS provide Rapid Application Development platform. It got a variety of useful frameworks using which you can rocket speed your application development.

Anything is possible using nodejs, cross-platform OS applications using electron js, backend server using express js, front-end apps using Angular, Vue, React. IoT apps using Node-Red, machine learning using ml.js

So the thing is if you are master in javascript you can do anything.

Enjoy learning NodeJS!