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

115
Views
JavaScript SetTimeout event loop latency problems

For example,

for (var i = 0; i < 3; i++) {
  setTimeout(function() {
    console.log(i)
  }, 500);

  let j = i;
  setTimeout(function() {
    console.log(j);
  }, 1000)
}

The event loop loupe result: 3 0 3 1 3 2

But in jsfiddle result: 3 3 3 0 1 2

I dont know what cause the two different results and which one would be the correct one.

about 4 years ago · Juan Pablo Isaza
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!