According to Mozilla , only Promises expects a wait:
[rv] Returns the allowed value of a promise, or the value itself if it is not a promise.
If you expect an immediate promise, the promise will be returned immediately and it will not wait. However, the following code expects without using Promises in Chrome and FF.
var obj = {
then:func => obj.func=func
};
setTimeout(() => obj.func(57), 1000);
async function go() {
var res = await obj;
console.log(res);
}
go();
According to the specifications, are promising objects that are not Promises awaiting expectations? (I tried to look at the specifications (related to the Mozilla article), but I couldn't figure it out.)
source
share