To find the array index with a value with JavaScript, we use the indexOf
method.
For instance, we write
const imageList = [100, 200, 300, 400, 500];
const index = imageList.indexOf(200);
to call imageList.indexOf
with 200 to return the first index of 200 in the imageList
array.