Writing asynchronous code
Although modern JavaScript brings promises and ES8 brings in async/await (which we'll see soon), still, there will be times when you'll encounter old APIs using callback mechanism/event-based mechanisms for their asynchronous operations.
It is important to understand the working of older asynchronous coding practices. This is because you cannot convert a callback-based asynchronous code piece to shining promises/async-await-based code without actually understanding how it works!
JavaScript, earlier, natively supported two patterns for writing asynchronous code, that is, the event pattern and the callback pattern. While writing asynchronous code, we usually start an asynchronous operation and register the event handlers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access