I'm new to javascript.
I'm trying to find the index of a specific element in an array. I read about that I can use findIndex to loop through an array. But it seems that findIndex only accept three arguments: element, index and array. What if I want change the object that is used to be compared.
For example, I want for find the index of string 'b' in array ['a','b','c'],
var position = ['a','b','c'].findIndex(function(element, index, array){return element==='b'})
but how do I pass 'b' as parameters that I can change to callback function
Thanks
findIndexaccepts 2 arguments: callback and optional context. It is a callback that is being called with 3 arguments.