Native JavaScript Promises and Browser APIs

One of the interesting evolutions of mainstream JavaScript development has been the widespread adoption of Promises. Promises simplify asynchronous code. Since JavaScript in the browser uses a single-threaded, callback-based programming model, asynchronicity is everywhere.

The Problem with Asynchronicity

Asynchronous patterns are great for keeping UIs responsive and non-blocking, but they have a cost: asynchronous JavaScript code tends to be highly nested, which hurts readability. Additionally, because you can't catch errors that are thrown inside callbacks from outside those callbacks, error handling needs to be spread throughout every level of nesting.

When we use Promises, our code structure is flattened, and our error handling continue.

tagged as , , and