Hacker News new | ask | show | jobs
by vorticalbox 22 days ago
async/await didn't hit javascript until 2017. in 2015 you picked between

function foo(cb) { cb(42, null) }

or

function foo() { return new Promise((resolve, reject) =>{ resolve(42) }) }

the second allowed for .then and .catch

foo.then((value) => console.log(value)).catch((error) => // handler error)

which isn't much better but did get us chaining

foo().then((v) => bar(v)).then((v) => baz(v)).catch()