Question: I already had an answer to this question, but I am struggling to understand how the event loop works. If someone could when and why
I already had an answer to this question, but I am struggling to understand how the event loop works. If someone could when and why things happen, that'd be great.
Considering the following JS/HTML code:

This code runs on a computer of a super-user, who clicks the button myButton 6 milliseconds after the execution starts.
What happens at particular time points?
Write an integer number in each of the text boxes. If something mentioned in the left column on the table does not happen, then write "-1" (negative one) in the corresponding right column.
| what happens | at what time (milliseconds) |
| `clickHandler` finishes | _ milliseconds |
| `clickHandler` starts | _ milliseconds |
| interval fires for the first time | _ milliseconds |
| interval fires for the second time | _ milliseconds |
| interval fires for the third time | _ milliseconds |
| interval fires for the fourth time | _ milliseconds |
| `intervalHandler` starts | _ milliseconds |
| `intervalHandler` finishes | _ milliseconds |
| mainline execution starts | 0 milliseconds |
| mainline execution finishes | _ milliseconds |
| promise handler starts | _ milliseconds |
| promise handler finishes | _ milliseconds |
| promise resolved | a tiny bit after _ milliseconds |
| `timeoutHandler` starts | _ milliseconds |
| `timeoutHandler` finishes | _ milliseconds |
| timer fires | _ milliseconds |
| user clicks the button | 6 milliseconds |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
