How to get index in jquery each function?

I have a list of elements and I want to loop all the elements. In jQuery, I can use .each() function to loop the list elements.

$('.elements').each(function(){
    // loop
});

Now how do I get the index in each loop?
I can set a variable outside the loop and increase it in each loop.

let i = 0;
$('.elements').each(function(){
     // loop
     console.log(i);
     i++;
});

But I don’t want to do that. Is there a default way to get the index?

jQuery each function provides 2 parameters in its callback one is index another is element

.each(function(index, element){  });

You can also use the first parameter only for the index.

$('.elements').each(function(index, element){
     console.log(index);
});