---
title: "Comment by Thamaraiselvam on \"Task Queue and Job Queue - Deep dive into Javascript Event Loop Model\" | Hashnode"
description: "Thanks for great Article. Cartoon Jerry //These micro task has precedence over macro tasks I am a Promise, right after tom and doggy! Really? I am a Promise aft"
url: "https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/5cb464fb05431a14119e1935"
---

[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)

[Thamaraiselvam](https://hashnode.com/@thamaraiselvam)

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

Thanks for great Article.

Cartoon

Jerry

//These micro task has precedence over macro tasks

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

I am a Promise after Promise!

//Finally macro tasks

Doggy

Tom

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

[Apr 15, 2019](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/5cb464fb05431a14119e1935#reply-5cb4697d05431a14119e19bd)

1.  First the function cartoon gets into the Stack.
2.  Next in call stack, Console.log('Cartoon') gets executed
3.  Next in call stack, setTimeOut -> tom is web api, so tom goes to TaskQueue but has not been executed yet.
4.  Next in call stack, setTimeOut -> doggy is web api, so doggy goes to TaskQueue but has not been executed yet.
5.  Next promise in call stack, the then() callback goes to job queue but has not been executed yet.
6.  Next another promise in call stack, the then() callback goes to job queue but has not been executed yet.
7.  Next in call stack, is jerry().
8.  Next in call stack, console.log('Jerry').
9.  At this point, nothing in Call Stack. The event loop looks into both the Queues. Gives priority to Job Queue over Tasks Queue.
10.  Execute both the promises callbacks from Job Queue by pushing those to Call Stack one by one.
11.  Now both Call Stack and Job Queue are empty. The Event Loop executes both the tasks from Task Queue.

So the expected output would be:

-   Cartoon
-   Jerry
-   I am a Promise, right after tom and doggy! Really?
-   I am a Promise after Promise!
-   Doggy
-   Tom

You were very close. Well tried and Thanks for trying. Thumbs up for it!

[Thamaraiselvam](https://hashnode.com/@thamaraiselvam)

[Thamaraiselvam](https://hashnode.com/@thamaraiselvam)

[Apr 15, 2019](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/5cb464fb05431a14119e1935#reply-5cb4c3cbd2d376ca1cc6017a)

oops yes your are correct

[Vedamruta Udavant](https://hashnode.com/@vedamruta)

[Jul 27, 2023](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/5cb464fb05431a14119e1935#reply-64c2d014513c1c494e44eecf)

[Tapas Adhikary](https://hashnode.com/@atapas) I didn't understood the 11th point in the above explanation. setTimeout(tom, 50); setTimeout(doggy, 30); The task queue is filled this way: \[tom(), doggy()\] So why isn't the output this because task queue is a task so FIFO no matter the timeout duration: Cartoon Jerry I am a Promise, right after tom and doggy! Really? I am a Promise after Promise! Tom Doggy

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

[Jul 28, 2023](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/5cb464fb05431a14119e1935#reply-64c38e63f5fc5651f9e85e4c)

[Vedamruta Udavant](https://hashnode.com/@vedamruta) No for setTimeout, setInterval kind of web APIs it will be filled based on the delayed time. That's the catch you need to keep in mind. So it will \[doggy(), tom()\] this way.

[Vedamruta Udavant](https://hashnode.com/@vedamruta)

[Jul 28, 2023](https://hashnode.com/posts/task-queue-and-job-queue-deep-dive-into-javascript-event-loop-model/5cb431d905431a14119e1777/comment/5cb464fb05431a14119e1935#reply-64c3a1acf5fc5651f9e86211)

[Tapas Adhikary](https://hashnode.com/@atapas) Got it, thank you 😄
