Unit 7. Working asynchronously

JavaScript has always been an asynchronous language. That makes it a perfect language for creating rich applications, because it can handle many concurrent tasks without locking the interface. But until recently, there hasn’t been much first-class support for its asynchronous nature other than being able to pass around functions that can be invoked at a later time. That has all changed. JavaScript now has first-class support for promises, asynchronous functions, and soon, for observables.

Promises are objects that represent future values. They are more convenient to pass around than callbacks because, unlike callbacks, they don’t rely on timing. A promise will give a value right away if the value has already been ...

Get Get Programming with JavaScript Next now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.