I use to declare all the objects I need at the top of my functions, which I use to cache and keep the app fast. For example I have something like:
var $object1 = $('#my_element'), $object2 = $('.other_elements'), $object3 = $('.again_something_else'); I use those variables in the code individually, so for example $object1.doSomething() or $object2.doElse() but in some scenarios I need to apply the same function to two or more already selected variables. There is a way to merge those variables together, to avoid re-selecting of the elements I need?
I would avoid this:
$('#my_element, .other_elements').myFunction() and reuse the variables I have already.
.each()does?