I am trying to find the index of an array inside another array in Javascript, as below:
const piece = [5, 10];
const array = [[5, 10], [5, 11]];
//Using indexOf
console.log(array.indexOf(piece));
//Using findIndex
console.log(array.findIndex(function(element) {
return element == piece;
}));
I'm expecting these to return a 0 as that is the index where my "piece" is inside the larger array, but both methods return -1
Any ideas why this is happening? And if there is a different way for me to do this?
Thanks.