Don’t forget that
$.each() do two different things in jQuery.
I’ve spent ages before banging my head because a piece of code wasn’t working as expected, and it ended up being because I wrote the wrong version of $.each.
$('selector').each(...) will iterate over the selected elements, while
$.each(variable, ...) will iterate over the object/array.