I have two arrays and I'm trying to check if they contain the same data, without caring about the order.
Is there a simple and fast way to do this?
const array1 = ['foo', 'apple', 'bar'];
const array2 = ['bar', 'apple', 'foo'];
if (array1.length === array2.length && array1.every(function(value, index) {
return value === array2[index]
})) {
console.log("Contain the same data");
} else {
console.log("Do not contain the same data");
}