Js loop two arrays match some key equal to operate

is there any other way to find an instance in the for nesting I use

Mar.23,2021

for (var i=0;i<array1.length;iPP){
    var j = array2.indexOf(array1[i]);
    if (j > -1){
        console.log(i);
        console.log(j);
        break;
    }
}

or use the findIndex method in ES6

var i = array1.findIndex(function(value,index,arr){
    return (array2.indexOf(value) > -1);
})

var j = array2.indexOf(array1[i]);
console.log(i,j)
Menu