eksea
2015-07-03 00:42
function typeOf(ele) {
var r;
if(ele === null) r="null";
else if(ele instanceof Array) r="array";
else if(ele === window) r= "window";
else if(ele instanceof Date) r="date";
else r = typeof ele;
return r;
}
function arraysSimilar(arr1, arr2){
if(!(arr1 instanceof Array) || !(arr2 instanceof Array))
return false;
if(arr1.length !== arr2.length)
return false;
for(var i = 0; i < arr1.length; i++) {
arr1[i] = typeOf(arr1[i]);
arr2[i] = typeOf(arr2[i]);
}
arr1.sort();
arr2.sort();
return arr1.toString()==arr2.toString();
}
111
JavaScript深入浅出
281102 学习 · 1020 问题
相似问题