Reputation: 21285
Say, JavaScript is in the middle of executing some method, and I'm pressing a button which has some event handler attached. Will the current method execution get paused and the click event handler start executing right away, or will js finish method execution and only then proceed with executing the click event handler?
Upvotes: 6
Views: 95
Reputation: 6126
The currently executing code will continue running until it has returned and then the next event will be run out of the event queue. Will be most likely your mouse click event.
Upvotes: 2
Reputation: 38264
The event will fire after the current Javascript finishes execution, since Javascript is single threaded. This is also why your browser can lock up.
Upvotes: 5