Purpose of index here is that e.g, using the following code when multiples elements are selected, index represents the number of the element from the selected multiple elements
$('.test').text((i, originalText) => {
return 'updated value of' + i;
});
multiple elements can have the 'test' class, so index represents the number of the current element on whom the text function is being executed right now