The index of the current element of the array?

Hi all. I know that the array index can be found using IndexOf, which pass the value of the desired element. But if my array is, for example from [1, 2, 3, 4, 4, 4, 4, 5], and I need the index of the third Quartet, there will be a value equal to 5. But in this case using [1, 2, 3, 4, 4, 4, 4, 5].indexOf(4) will return the value 3, as it will meet the top four in third position. But how can you get the index of the element that I need, that is the index of the third Quartet?
July 5th 19 at 00:01
1 answer
July 5th 19 at 00:03
logArrayElements function(element, index, array) {
 console.log('index[' + index + '] = ' + element);
}
[1, 2, 3, 4, 4, 4, 4, 5].forEach(logArrayElements);

Find more questions by tags JavaScript