
Building a JavaScript Promise from Scratch - ksashikumar
https://medium.com/gitconnected/understand-javascript-promises-by-building-a-promise-from-scratch-84c0fd855720
======
wakeywakeywakey
There is a subtle issue here: all parts of the suggested promise
implementation run synchronously.

In spec-compliant promises, the executor runs synchronously [1][2], but the
promise must wait until the next turn of the event loop [3] before calling the
'then' method.

[1] [https://stackoverflow.com/questions/36726890/why-are-
javascr...](https://stackoverflow.com/questions/36726890/why-are-javascript-
promises-asynchronous-when-calling-only-synchronous-functions)

[2] [https://stackoverflow.com/questions/36932244/what-is-the-
int...](https://stackoverflow.com/questions/36932244/what-is-the-intention-
behind-clause-2-2-4-of-promise-a-spec)

[3] [https://github.com/promises-aplus/promises-
spec/issues/68](https://github.com/promises-aplus/promises-spec/issues/68)

