From the course: Learning Node.js

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Asynchronous tasks and callbacks

Asynchronous tasks and callbacks - Node.js Tutorial

From the course: Learning Node.js

Start my 1-month free trial

Asynchronous tasks and callbacks

- [Narrator] When you execute a task synchronously, you wait for it to finish before moving on to another task which is what causes blocking. On the other hand, when you execute tasks asynchronously, you can move on to another task without having to wait for the previous task to finish. For example, if you've ever used an application or a website where you had to submit a form and everything went gray until the response was received, that's the background process running synchronously and blocking the responsiveness of the user interface until it completes. If we were to make a list of all the things you could do on a computer and ordered them based on their completion time, there would be two that require relatively long waiting times: networking access and file system access. And with a web app, these are some of the most common functions. This is why Node performs so well for web apps. The most common way to get started with asynchronous code is to do callbacks. So let's take a…

Contents