Showing posts with label promise. Show all posts
Showing posts with label promise. Show all posts

Friday, December 5, 2014

How Asynchronous JavaScript Promises Work

The Promise object in the proposed ECMAScript 6 specification makes performing asynchronous operations easier. Not necessarily Ajax requests, but local function calls. These functions themselves may or may not depend on an external resource, but the key to promises is that the API looks and behaves the same. Promises, out of the box, are asynchronous. Let's illustrate the idea with some code: