based on: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/EventLoop
stack frame is empty before next event is processed. So why in folowing snippet alert displays 1 instead of 0 because alert function should run before callback
var a=0;
var b={};
$(b).on("event", function (){
a++;
});
$(b).trigger("event");
alert(a);
Thanks!
;characters are optional (from the point of view of the author, not the the interpreter). It just leads to horrible, horrible problems when they're automagically inserted by the interpreter (which often inserts them in unexpected, or unanticipated, places).