O'Reilly logo

Async JavaScript by Trevor Burnham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 1Understanding JavaScript Events

Events. How do they work? Confusion about JavaScript’s asynchronous event model is as old as JavaScript itself. Confusion leads to bugs, bugs lead to anger, and Yoda taught us the rest….

Yet at heart, JavaScript events are both conceptually elegant and practical. Once you’ve accepted the language’s single-threaded design, it feels like a feature rather than a limitation. It means that your code is uninterruptible and that the events you schedule line up in an orderly fashion.

In this chapter, we’ll take a tour of JavaScript’s asynchronous mechanisms and dispel some common misconceptions. We’ll see what setTimeout really does. Then we’ll discuss handling errors in callbacks. Finally, we’ll set up ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required