6

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?

1

2 Answers 2

5

The event will fire after the current Javascript finishes execution, since Javascript is single threaded. This is also why your browser can lock up.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.