Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Question about 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 the click event handler?

like image 628
Andrey Avatar asked Sep 22 '11 20:09

Andrey


1 Answers

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

like image 158
Digital Plane Avatar answered Sep 18 '22 10:09

Digital Plane