For anyone who has decided the brave the world of web development, they will have inevitably come across the concept of asynchronous programming. Asynchronous programming refers to the idea that we should allow for some function or piece of code to finish running before firing off another piece of code. In other words, one forces synchronicity for some system that naturally occurs in an asynchronous manner. One such manner of achieving this goal is by using callback functions, as shown below.
However, using callbacks comes at the cost of readability and potentially lends to a problem known as callback hell, wherein callback functions are stacked back to back. One method of avoiding this issue is by making use of promises. Promises are defined by their distinct ‘.then()’ clause and allow for the writing of more easily understood code at the cost of slight decreases to performance speed. Shown below is one such example of the elegant promise.

