From the course: Learning Node.js
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Asynchronous tasks and callbacks - Node.js Tutorial
From the course: Learning Node.js
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.