不太明白第八组null和object的比较为什么不对,还有第9组和第11组要求是false是因为这两组不是数组吗,那我的代码需要怎么改
function arraysSimilar(arr1, arr2){
var typeArra1=[],typeArra2=[],Similar=false;
if(arr1 instanceof Array&&arr2 instanceof Array){
for(var i=0;i<arr1.length;i++){
typeArra1[i]=getTypes(arr1[i]);
typeArra2[i]=getTypes(arr2[i]);
typeArra1.sort();
typeArra2.sort();
if(typeArra1.toString()==typeArra2.toString()){
Similar=true;
}
}
}else{
/* if(getTypes(arr1)==getTypes(arr2)){
Similar=true;
};*/
}
console.log(typeArra1.toString());
console.log(typeArra2.toString());
console.log(Similar);
return Similar;
}
function getTypes(obj){
var type=typeof obj;
if(type!="object"){
return type;
}else if(obj instanceof Date){
return "date";
}else if(obj === null){
return "null";
}else if(obj === window){
return "window";
}else {
return "object";
}
}