Async/Await: a Game Changer for Haters of Promise Chaining
...If you became a frontend engineer after 2015, chances are that you have used or at least heard about
Promise. As I have covered in my previous blog,Promisecan help us specify sequential relations between operations in asynchronous programming in a readable and maintainable manner.Promiseobject in JavaScript has methods, such asthenandcatch, that can help us organize the sequential execution of operations in a pattern called Promise Chaining. Clean and organized as Promise Chaining is, some people—especially those more accustomed to synchronous programming—find it unintuitive and confusing. Lucky for them, ECMAScript 2017 introduced a new feature that allows us to write asynchronous code as if it were synchronous. This new feature consists of two keywords:asyncandawait. In this article, I will cover the fundamentals ofasync/awaitand how to transition from Promise Chaining to usingasync/await.The Whys and Hows of Promise in JavaScript
...If you have done any web development after 2015, chances are that you have heard of the concept of Promise. It wouldn’t be an overstatement to claim that Promise is ubiquitous in modern-day front-end codebases. However, many web developers—especially those who do not have much experience in front-end development—have been using Promise without thoroughly understanding its inner working. This has led to countless misuses of Promise and consequent bugs. In this article, I will walk you through what motivated the creation of Promise, how Promise works, and how we should use it in our code, under the assumption that you don’t have much experience in front-end development.