Pre-ES6
ES51995 – 2014One function scope, one binding keyword, and callbacks all the way down. Everything that came later is a reaction to this era's sharp edges.
Before Promises, asynchrony meant passing continuations. Errors travelled as a first argument by convention — nothing in the language enforced it.
function readValue(key, cb) {
setTimeout(function () {
cb(null, key.toUpperCase());
}, 0);
}
readValue("a", function (err, a) {
readValue(a + "b", function (err, b) {
readValue(b + "c", function (err, c) {
console.log("nested result:", c);
});
});
});