Synchronous

It waits for one operation to be completed before it handles and executes the second operation.





Asynchronous

It does not wait for one operation to be completed, rather it executes all the operations in the one go.





NodeJS

NodeJS is simply JavaScript written in C++. It runs on the V8 engine as JavaScript does but uses asynchronous programming.

What makes NodeJS asynchronous?

The first question which comes to the mind is how NodeJS is asynchronous when V8 and JavaScript follow a synchronous way of handling operations.





The answer is - Event Loop!

NodeJS has libUV which runs event loop periodically to check if there are events in the queue to be processed.



When a request has been sent to the OS (file opening, downloading a file etc.), it returns as an event to libUV. The event loop in libUV keeps checking the queue inside the libUV if something has happened. Whatever happens, it gets placed in the queue as an event. When an event finishes, libUV processes it and sends it to V8 as a callback.



At the same time, V8 is already running and is processing a code. Since it is synchronous in nature, it will let the current code finish executing first and then handles the callback.



Since the whole process of events coming from the OS, event loop in libUV checking the queue if an event is happening or done processing, V8 running the code synchronously and receiving the callback from libUV when an event is done processing happens inside NodeJS at the same time, it makes NodeJS asynchronous in nature.



This explains the Event-Driven programming in NodeJS. It simply means the programming which acts on events and whole paradigm of NodeJS is based on events.





There are 2 ways of handling requests and executing them in programming:JavaScript runs on the V8 engine and both JavaScript and V8 follow the synchronous way of handling operations. That's why NodeJS is here which follows the asynchronous way, eliminating the waiting time for the previous operation to be completed. For the same reason, it is also tagged as "". Theterm is associated with NodeJS for its async behavior which does not block any other operations to happen. For thepart, let's dig a little deeper!