I saw like many people answered that jQuery each() function isn't asynchronous. But I don't understand why this function behaves a certain way. Could anybody explain why this code:
var otherArray = [1, 2, 3, 4, 5];
var array = [];
console.log(array);
$(otherArray).each(function () {
array[1] = $(this);
});
has this output:
But that code:
var otherArray = [1, 2, 3, 4, 5];
var array = [];
console.log(array);
$(otherArray).each(function () {
// array[1] = $(this);
})
has that output: