how to compare two arrays javascript
function arraysAreIdentical(arr1, arr2){
if (arr1.length !== arr2.length) return false;
for (var i = 0, len = arr1.length; i < len; i++){
if (arr1[i] !== arr2[i]){
return false;
}
}
return true;
}// For regular 1D array
const array1 = [1,2,3,4]
const array2 = [1,2,3,4]
array1.join() === array2.join()
// '1,2,3,4' === '1,2,3,4'
// For anything more complex
const array3 = [1,2,3,[1,2,3]]
const array4 = [1,2,3,[1,2,3]]
JSON.stringify(array3) === JSON.stringify(array4)
Also in JavaScript:
- javascript select letter in string
- update angular website firebase
- hide and show in angular 8
- single node elasticsearch with enable security basic in docker
- js delete all array items
- oneerror javascript image
- page is loading from previous page scroll in reactjs
- add table row jQuery
- flutter intl currency
- javascript test if it is an array
- jquery ajax on fail
- email validation in javascript
- Javascript measure function run time
- How do you detect whether or not a word is a palindrome in javascript
- post json in flutter
- javascript input onchange get value
- Texto unitário no node js
- javascript cast bool to int
- inheritance in javascript
- what is promise in javascript
- unexpected template string expression no-template-curly-in-string react
- how to add data to array in javascript dynamically
- heap sort javascript
- mixin in styled components