Skip to content

Instantly share code, notes, and snippets.

@zzuhan
Last active December 30, 2015 18:49
Show Gist options
  • Save zzuhan/7869850 to your computer and use it in GitHub Desktop.
Save zzuhan/7869850 to your computer and use it in GitHub Desktop.
判断数组是否相等,不考虑顺序
/**
* Array comparsion, ignore order
* 比较对象都是比较是否是指向同一个对象
*/
function inArray(array, input){
for(var i=array.length; i--; ){
if(array[i] === input) return true;
}
}
function isEqArray(arr1, arr2){
if(arr1.length !== array2.length) {
return false;
}
for(var i = arr1.length; i--; ) {
if(!inArray(arr2, arr1[i])) {
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment