.each()
.each( callback ( index Int, n Element, arr array) ): self
Iterates throught the elements matched, executes a callback function for each iteration.
Difference between .each() vs .forEach()
.forEach() acts as the regular Array.forEach(), where the arguments order is the callback is item, index, arrayIn
.each() similarly to jQuery the index argument comes first: index, item, array// No arguments
$( "p" ).each(function() {
console.log( $( this ).text() );
});
// With arguments
$( "p" ).each(function( index, el, arr ) {
console.log( 'Paragraph ' + index + ": " + $( this ).text() );
});