The Evolution of and Motivation for Promises
As we've learned, a callback is a function that is given as an argument to another function, in effect saying, "do this when you are done." This capability has been in JavaScript since its inception in 1995 and can work very well, but as the complexity of JavaScript applications grew through the 2000s, developers found callback patterns and nesting in particular to be too messy and unreadable, giving rise to complaints about "callback hell" as shown in the following example:
doSomething(function (err, data) { if(err) { console.error(err); } else { request(data.url, function (err, response) { if(err) { console.error(err); } else { doSomethingElse(response, function (err, data...