没毛病吧这个代码
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
/*
* param1 Array
* param2 Array
* return true or false
*/
function arraysSimilar(arr1, arr2){
if(arr1.length!==arr2.length){
return false;
}
var str=0,bool=0,num=0,func=0,date=0,win=0,undef=0,nul=0;
for(const i of arr1){
switch(typeof i){
case 'string':
str++;
break;
case 'boolean':
bool++;
break;
case 'number':
num++;
break;
case 'function':
func++;
break;
case 'date':
date++;
break;
case 'window':
win++;
break;
case 'undefine':
undef++;
break;
case 'null':
nul++;
break;
}
}
for(const i of arr2){
switch(typeof i){
case 'string':
str--;
break;
case 'boolean':
bool--;
break;
case 'number':
num--;
break;
case 'function':
func--;
break;
case 'date':
date--;
break;
case 'window':
win--;
break;
case 'undefine':
undef--;
break;
case 'null':
nul--;
break;
}
}
if(str||bool||num||func||date||win||undef||nul){
return false;
}
return true;
}
function f1(){
}
function f2(){
}
let arr1=[1,f2],arr2=[1,f1];
if(arraysSimilar(arr1,arr2)){
alert("判定结果:通过");
}
else{
alert("判定结果:不通过");
}
</script>
<script src="testData.js"></script>
</body>
</html>