Is there a specific specification or implementation detail that dictates how quickly the callbacks of a promise are evaluated? For example, if I have:
var promise = new Promise((resolve) => {
resolve()
});
console.log(promise); // there is no public field '<state>', but you can see it in the console of the dev tools
I notice that the promise
is already fulfilled immediately. I expected that the Promise
would wait to call the resolve
callback at a later time, leaving a "time window" where the promise
remains unfulfilled.
Is this quick evaluation of the resolve
callback intentional design, or is it simply an implementation detail?