In jQuery, what's the difference between the following two constructions of jQuery.each
:
// Given
var arr = [1,2,3,4],
results = [],
foo = function (index, element) {
/* something done to/with each element */
results.push(element * element); // arbitrary thing.
}
// construction #1
$.each(arr, foo); // results = [1,4,9,16]
// construction #2
$(arr).each(foo); // results = [1,4,9,16]
Is there any difference, or is it purely syntax?