Last active
December 30, 2015 18:49
-
-
Save zzuhan/7869850 to your computer and use it in GitHub Desktop.
判断数组是否相等,不考虑顺序
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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