通过了,但是觉得 会不会这写法太臃肿了?
function arraysSimilar(arr1, arr2){
var result = false;
var arr1Type = Object.prototype.toString.call(arr1);
var arr2Type = Object.prototype.toString.call(arr2);
var typeObj={};
if(arr1Type=='[object Array]'&&arr2Type=='[object Array]'){
result = arr1.length==arr2.length;
for(var i=0;i<arr1.length;i++){
var type = Object.prototype.toString.call(arr1[i]);
typeObj[type] = true;
}
for(var i=0;i<arr2.length;i++){
var type = Object.prototype.toString.call(arr2[i]);
if(typeof typeObj[type]!=="undefined"){
result = true;
} else {
result =false;
return result;
}
}
}
return result;
}