Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
Execution Order in Event Loop

why setTimeout(callback), Promise.resolve().then(callback) and requestAnimationFrame(callback) have different priority to execute? Following is a code sample:

setTimeout(()=>console.log(1));
Promise.resolve(2).then(console.log);
requestAnimationFrame(()=>console.log(3));
console.log(4);
window.onclick = ()=>console.log(5);
window.dispatchEvent(new Event('click'));

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

synchronization

  console.log(4);
  window.onclick = ()=>console.log(5);
  window.dispatchEvent(new Event('click'));

Micro tasks

 Promise.resolve(2).then(console.log);
  requestAnimationFrame(()=>console.log(3));

Macro task

  setTimeout(()=>console.log(1));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!