---
title: "Comment by Adrian Belen on \"Task Queue and Job Queue - Deep dive into Javascript Event Loop Model\" | Hashnode"
description: "Can you please explain this me why the event loop prioritize cartoon&#39;s setTimeouts than the then&#39;s setTimeout? Ok, I did some changes here const tom = ("
url: "https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/60c81639590a5c0656565600"
---

[Discussion](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777)

Comment [Task Queue and Job Queue - Deep dive into Javascript Event Loop Model](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777)

[Adrian Belen](https://hashnode.com/@stepOniichan)

[Jun 15, 2021](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/60c81639590a5c0656565600)

Can you please explain this me why the event loop prioritize cartoon's setTimeouts than the then's setTimeout? Ok, I did some changes here

```
const tom = () => console.log('Tom');
const jerry = () => console.log('Jerry');
const doggy = () => console.log('Doggy');

const cartoon = () => {
  console.log('Cartoon');

  setTimeout(tom, 0);
  setTimeout(doggy, 0);

  new Promise((resolve, reject) =>{
      resolve('I am a Promise, right after tom and doggy! Really?');
    setTimeout(()=>{console.log('inner timeout')},0)
  }
  ).then(resolve => console.log(resolve));
  new Promise((resolve, reject) =>
    resolve('I am a Promise after Promise!')
  ).then(resolve => console.log(resolve));

  jerry();
}

cartoon();
```

"Cartoon"

"Jerry"

"I am a Promise, right after tom and doggy! Really?"

"I am a Promise after Promise!"

"Tom"

"Doggy"

"inner timeout"

[Jalaj Gupta](https://hashnode.com/@jalaj)

[Jun 27, 2021](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/60c81639590a5c0656565600#reply-60d8943dcb0aa8118c23cdaf)

I think it doesn't matter if the setTimeout is inside `then`, because it will still get added to the TASK queue and since all the timers are 0, they will get executed in order they got en-queued. `tom -> doggy -> inner timeout`

[Tapas Adhikary](https://hashnode.com/@atapas)

[Aug 25, 2021](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/60c81639590a5c0656565600#reply-61260b1ab115357df05f5990)

[Jalaj Gupta](https://hashnode.com/@jalaj) , That's absoloutely correct.
