The things is that PHP just goes through your code once. You give the server a request and he gives you a response.
With JS stuff happens caused by events. And this can also mean that multiple events can be triggered while another events is still being handled and then the exact timing can be relevant and you run into concurrency issues and then stuff gets really confusing with events spread all over the place.