javascript Compare two arrays regardless of order
const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
// Examples
isEqual([1, 2, 3], [1, 2, 3]); // true
isEqual([1, 2, 3], [1, '2', 3]); // falsefunction 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;
}
Also in JavaScript:
- mask date of birth/ dob in javascript
- pass variable to regrex literal notation javascript
- duplicate encoder
- fizzbuzz js
- create json string c#
- javascript append array to array
- sum elements in list with same name js
- agrgar atributo con id jquey
- how to use await to console
- jquery table row calculation
- react app cloud foundry 404
- date picker type react
- angular datatable reload with pagination
- convert datetime javascript mysql
- javascript construct new object
- how to sent react from data in mongodb
- tick.json code
- javascript check if string contains a text substring
- javascript check if set contains
- js get alphabet as array
- regex to get part of word nodejs
- express.json vs bodyparser.json
- Javascript modify URL without reload
- i18n react meta description