Please look at these four setTimeout functions and their execution parts
P粉304704653
P粉304704653 2023-09-17 18:04:25
0
1
433

//1
setTimeout(() => {
  console.log('hi');
}, 5000)

//2
setTimeout(() => {
  console.log('hello');
}, 3000)

//3
setTimeout(() => {
  console.log('bye');
}, 0)

//4
setTimeout(() => {
  console.time('the code took:');
  let i = 10000
  while (i--) {
    console.log(i);
  }
  console.timeEnd('the code took:')
}, 7000)

Here I wrote four setTimeout functions. According to my understanding, they will start executing at the same time in the callback queue, right? If I'm right, then my question is whether the fourth setTimeout() function has completed half or more than half of its execution in the callback queue or does it start from the beginning after 7 seconds after being pushed into the call stack implement? So what's going on behind the scenes?

P粉304704653
P粉304704653

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!