4 ms·
Ask HN: (JS) Wouldn't it be simpler if `await` were a method on `Promise`?
Instead of requiring special new syntax like we have now:
const result = await doAsync();
We could have a method on the returned Promise object called 'await':
const result = doAsync().await();
- neilk 8y ago1) There could be an `await` method already defined on the Promise. It's just an object. 2) `await` can work with anything that conforms to the Promise spec, native promises or Bluebird or what have you. 3) Sometimes, a method doesn't return a Promise, but a value. In those cases, the await syntax returns the value. Can't do that with a method.