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

73
Views
Asynchronous Window Closing Javascript
let counter = 0;
const openInterval = setInterval(() => {
    setTimeout(() => {
        console.log("setTimeout", counter);
        newWindow.close();
    }, 9000);

    newWindow = window.open("https://google.com");
    counter++;
    console.log("setInterval", counter);
    if (counter === 5) {
        console.log("END", counter);
        clearInterval(openInterval);
    }
}, 10000);

The set interval function opens a new window every 10 seconds, the setTimeout function runs 9 seconds after a window is opened, but it fails to close the window, and there wasn't an error in the console, how can this be fixed?

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!