check if array is equal code example
Example 1: check if numpy arrays are equal
(A==B).all()
Example 2: check if 2 arrays are equal javascript
var arraysMatch = function (arr1, arr2) {
// Check if the arrays are the same length
if (arr1.length !== arr2.length) return false;
// Check if all items exist and are in the same order
for (var i = 0; i < arr1.length; i++) {
if (arr1[i] !== arr2[i]) return false;
}
// Otherwise, return true
return true;
};
Example 3: check array values equal js
[1,1,1,1].every( (val, i, arr) => val === arr[0] ) // true