Re:Let’s make a JavaScript Wait function
by xg15 on Sunday November 12, 2017 @06:28PM
(#15683140)
Moreover, async/await allows you to preserve multiple intermediary results between async steps - which is awkward in both promises and un-nested pyramids like the OP's:
(not even starting with conditions, loops and recursive calls that contain async steps...)
Async/Await:
async function f(a) {
var b = await foo(a);
var c = await bar(a, b);
return baz(a, b, c);
}
(not even starting with conditions, loops and recursive calls that contain async steps...)
Async/Await:
Promises: Callbacks: Callbacks untangled: