Brazilian developer since 2011. Microsoft MVP, Docker Captain, and Google Dev Expert. OpenJS foundation member and Node.js contributor. Loves JavaScript and TypeScript.
Hi lucas, your explanation was great and crisp and output is also right according to your explanation setInterval wont get called. Before that settimeout 2 's micro task promises will get printed and then set interval macro task should proceed as next tick but because interval got cleared it wont.
Brazilian developer since 2011. Microsoft MVP, Docker Captain, and Google Dev Expert. OpenJS foundation member and Node.js contributor. Loves JavaScript and TypeScript.
Hi, Lucas!
The output above is from Chrome browser, Ubuntu.
Here is from Node.js v10.17.0 Ubuntu:
script start
promise 1
promise 2
setInterval
setTimeout 1
promise 3
promise 4
setInterval
setTimeout 2
promise 5
promise 6
It seems environment affects how is queuing of macro tasks is.
Yes, the environment might change the order of how some of the tasks are processed. Node uses libuv whereas Chrome does not.
Hi lucas, your explanation was great and crisp and output is also right according to your explanation setInterval wont get called. Before that settimeout 2 's micro task promises will get printed and then set interval macro task should proceed as next tick but because interval got cleared it wont.
Sorry, I did not understand your question, could you please rephrase it?