Event execution in JavaScript
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 t开发者_如何学编程he click event handler?
The event will fire after the current Javascript finishes execution, since Javascript is single threaded. This is also why your browser can lock up.
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.
精彩评论