比较直接的写法
function arraysSimilar(arr1, arr2){
if(!(arr1 instanceof Array) || !(arr2 instanceof Array) || arr1.length != arr2.length) {
return "判定结果不通过";
}
for(var i=0; i<arr1.length; i++) {
arr1[i] = arr1[i] == null ? null : Object.prototype.toString.apply(arr1[i]);
arr2[i] = arr2[i] == null ? null : Object.prototype.toString.apply(arr2[i]);
}
arr1.sort();
arr2.sort();
if(arr1.toString() != arr2.toString()) {
return "判定结果不通过";
}
return "判定结果通过";
}