I've recently learned that setTimeout is not part of Ecma 262 standard but takes part of WhatWG one.

I have one misunderstanding concerning these two standards and I can't get how they converge.

For now, setTimeout or setInterval, two ways of making Javascript asynchronous are part of the WhatWG spec.

Then and Ecma(script) 2015 comes out and offers Promise. I'm now able to check that it exists on the V8 public github repository.

My question is: How can the Promise spec be part of the Ecmascript standard since it's a micro task in the WhatWG standard?

I can't get how Promise can work OUTSIDE a WhatWG context (outside of an event loop?) but it seems feasible to run them outside this context: in an Ecmascript 2015 one.

What am I missing out there?

Thanks for your help

  • I'm not sure I understand why you think that the WHATWG spec would form a necessary part of ECMA-262/JavaScript? After all, JS is more than just a web browser scripting language. Your question might be clearer if you reference specific sections of specific versions of the specs. Also note that ECMA-262 6.0 (2015) defines a “Job Queue” concept, though the WHATWG spec also discusses how their event loop is not strictly compatible with that job queue… – amon Oct 16 '18 at 20:20
  • I don't think WHATWG is necessary a part of Ecma/Javascript. I just wanted to understand how Promises fit Ecmascript since they are asynchronous thanks to micro tasks in the WhatWG event loop one. How can they work outside whatwg event loop? – mfrachet Oct 16 '18 at 20:32
  • Just read the ECMA spec, starting with the Job Queue thing I linked. ECMA-262 Promises are not WHATWG microtasks. Instead, these promises are defined in terms of the ECMA-262 Job Queue. – amon Oct 16 '18 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.