So, what’s wrong with checking each element iteratively?
function arraysEqual(arr1, arr2) {
if(arr1.length !== arr2.length)
return false;
for(var i = arr1.length; i--;) {
if(arr1[i] !== arr2[i])
return false;
}
return true;
}
More Related Contents:
- Sort array of objects by string property value
- Comparing Arrays of Objects in JavaScript
- javascript surprising array comparison
- Deep comparison of objects/arrays [duplicate]
- Filter JSON by key value with JavaScript
- compare each 5 numbers of two array [closed]
- fetch first element of every string in array using javascript [closed]
- Convert string into several integer arrays [duplicate]
- Accesing 2d arrays from Javascript [closed]
- Best way to find if an item is in a JavaScript array? [duplicate]
- Most efficient way to create a zero filled JavaScript array?
- Sort array of objects by single key with date value
- How to group by and sum an array of objects? [duplicate]
- Group objects by multiple properties in array then sum up their values
- What is “undefined x 1” in JavaScript?
- Check if an array is empty or exists
- GetElementByID – Multiple IDs
- What is the most efficient way to sort an Html Select’s Options by value, while preserving the currently selected item?
- How to convert array into string without comma and separated by space in javascript without concatenation?
- JavaScript arrays braces vs brackets
- How much faster are arrays than accessing Google Sheets cells within Google Scripts?
- Getting index of an array’s element based on its properties
- JavaScript filter array by data from another
- Sum two arrays in single iteration
- What is the difference between “in operator” and “includes()” for JavaScript arrays
- How do I unset an element in an array in javascript?
- javascript – match string against the array of regular expressions
- How to flatten array in jQuery?
- Array.of vs “[ ]”. When to use Array.of over “[ ]”?
- Array of object deep comparison with lodash