How do I retrieve the index position of each element?:
$(myArray).each(function() {
console.log( ...this.indexOf()?.... )
}
Read the docs. The first argument to your callback is the index.
So:
$(myArray).each(function(index,item) {
console.log(index);
});
Side note: Array.forEach takes it's arguments in the opposite order (item first, then index) which, IMHO, feels more natural. I have no idea why jQuery ended up putting the arguments that way around.
.each()should be used only for jQuery object relative to DOM nodes, here you should use:$.each(myArray, function(index){console.log(index);})