JavaScript runs asynchronously, that means when you initialize $.each every bit of code that comes after that will not be executed when $.each has finished. Sometimes you need your code to be executed after each. I found out that the easiest way to do it is to use $.when and $.then.
Source code viewer
$.when( console.log(obj); }) ).then(function(){ alert('My after each event.'); }); Programming Language: jQuery