4 ms·
Building a JavaScript Promise from Scratch
- wakeywakeywakey 9y agoThere 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-javascript-promises-asynchronous-when-calling-only-synchronous-functions https://stackoverflow.com/questions/36726890/why-are-javascr... [2] https://stackoverflow.com/questions/36932244/what-is-the-intention-behind-clause-2-2-4-of-promise-a-spec https://stackoverflow.com/questions/36932244/what-is-the-int... [3] https://github.com/promises-aplus/promises-spec/issues/68 https://github.com/promises-aplus/promises-spec/issues/68