If you've ever done any amount of JavaScript programming, you have probably experienced callback hell. If you haven't, the following code should give you a good idea about what it is:
http.get('api/users/find?name=' + name, function(user){ http.get('api/orders?userId=' + user.id, function(orders){ orders.forEach(function(order){ container.append(order); }); }); });
This style of programming can easily get out of hand. Instead of writing more natural, sequential steps to achieve a task, that logic is instead scattered across multiple callbacks, increasing the developer's cognitive load.
In response to this, the JavaScript community released several promises libraries that are meant to solve this issue. We can think of promises as empty boxes we can pass into and return from our functions. At...