Actually Understanding Asynchronous JavaScript
Reasoning about asynchronous code can be hard if you don’t understand the mechanics. It often trips up programmers with deep experience in other languages when they try their hand at client or server-side JavaScript. But, asynchronous JavaScript isn’t as hard as it seems once you learn a few simple rules about how it works. In this talk, we’ll dive into the mechanics of concepts that you might have had a chance to full grok.
Let’s dispel this confusion once and for all. We’ll explore some metaphors that illustrate the difference between how synchronous and asynchronous code execute. In a 30-minute tour de force, we’ll dive into essential concepts like the call stack and the event loop to build a solid conceptual understanding of how the asynchronous model is implemented. We’ll take a good hard look at a number of common patterns for writing asynchronous code in JavaScript. We’ll start with listening for events on XMLHttpRequest before abstracting that mess with callbacks and promises. We’ll pull back the curtain and see that async/await is really just a cocktail of promises and generators. Finally, we’ll lightly touch upon some more boutique approaches like CSP and shooting messages back and forth between the main and worker threads.
EVENT:
NEJS CONF 2018
SPEAKER:
Steve Kinney
PERMISSIONS:
Original video was published with the Creative Commons Attribution license (reuse allowed).
CREDITS:
Original video source: https://www.youtube.com/watch?v=Av4vdFS0EmI
Additional material for JavaScript learners:
https://amzn.to/2JrUINQ Eloquent JavaScript, 3rd Edition: A Modern Introduction to Programming
https://amzn.to/2HwAMYd Simplifying JavaScript: Writing Modern JavaScript with ES5, ES6, and Beyond
https://amzn.to/2Cq5bmL JavaScript: JavaScript Programming.A Step-by-Step Guide for Absolute Beginners
https://amzn.to/2uhIvAP How JavaScript Works
https://amzn.to/2CwS2bU The Modern JavaScript Collection