我照着答案写的咋还不对呢?哪里错了?谁帮我看看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>unit1</title>
</head>
<body>
<script>
function arraySimilar(arr1,arr2){
//判断边界(判断是不是数组)
if(!(arr1 instanceof Array)||!(arr2 instanceof Array)){
return false;
}
//判断长度是否一致
if(arr1.length!==arr2.length) return false;
//计算各个类型的次数
//得到数组长度
var n=arr1.length;
//用count[]数组来存储arr中各个类型的次数
var countMap1=[];
var countMap2=[];
//获取数组对应序列的类型
var t1,t2;
//循环数
var i=0;
TYPSE=['string','boolean','number','undefined','null','function','date','window'];
for(;i<n;i++){
t1=typeOf(arr1[i]);
t2=typeOf(arr2[i]);
if(countMap1[t1]){
countMap1[t1]++;
}else{
countMap1[t1]=1;
}
if(countMap2[t2]){
countMap2[t2]++;
}else{
countMap2[t2]=1;
}
}
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;
}
for(i=0,n=TYPES.length;i<n;i++){
if(countMap1[TYPES[i]]!==countMap2[TYPES[i]])
return false;
}
return true;
}
</script>
</body>
</html>