From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext

Unlock this course with a free trial

Join today to access over 25,000 courses taught by industry experts.

Use callbacks to handle asynchronous operations

Use callbacks to handle asynchronous operations - JavaScript Tutorial

From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext

Use callbacks to handle asynchronous operations

- Now that we've seen a simple example of how to write and run JavaScript programs, it's time to take a look at a very important part of writing any modern JavaScript application, and that's working with asynchronous code. At the beginning of the course, I mentioned that JavaScript is single threaded. This means that while a JavaScript program is running, at any given moment, there can only be one operation that it's executing. And this makes JavaScript not particularly good at intensive applications that require true multi-threaded execution. But for the vast majority of JavaScript applications, the workarounds that JavaScript has in place are really more than sufficient. Basically, JavaScript has several techniques that allow us to write code that's single-threaded behind the scenes, but feels multi-threaded. The first of these techniques that we're going to talk about is using callbacks. You've most likely worked with callbacks at some point in the past and whatever language you're…

Contents