Currently engrossed in dive into the world of javascript with "professional javascript for web developers", focusing on the discussion about iterative methods for arrays such as every()
, filter()
, and more.
The book mentions that you need to pass functions that take three arguments: the value of the array item, the position of the item in the array, and the array object. This means all functions should look something like this:
function(item, index, array){
[do something with item]
}
But why exactly would you need to include the index
and array
arguments? Wouldn't just using item
suffice?