...

/

Callbacks, setTimeout, & the Event Loop

Callbacks, setTimeout, & the Event Loop

Learn how JavaScript is both single-threaded and asynchronous. We'll go over how the event loop creates an event-based system that is at the core of how modern websites work. We'll see how to respond to events efficiently and how to write asynchronous code.

We'll cover the following...

What Callbacks Do

Callbacks are absolutely vital to asynchronous programming. The only way for us to tell JavaScript to do something in the future is to provide a callback that will be invoked later.

JavaScript allows us to attach a callback to a particular event. We can tell JavaScript that when some event happens, we want to run some function. That’s the gist of the whole concept.

The event can be anything. In a browser, it can be a button click from a user. On a file system, it can be a file read ...

Access this course and 1400+ top-rated courses and projects.