<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb18030">
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
/*
* param1 Array
* param2 Array
* return true or false
*/
function arraysSimilar(arr1,arr2){
if(arr1 instanceof Array && arr2 instanceof Array){
if(arr1.length == arr2.length){
var hdlarr1 = getType(arr1).sort();
var hdlarr2 = getType(arr2).sort();
for(var i=0;i<hdlarr1.length;i++){
console.log(hdlarr1[i],hdlarr2[i]);
if(hdlarr1[i] !== hdlarr2[i]){
return false;
}
}
}else{
return false;
}
return true;
}else{
return false;
}
}
//返回数组类型
function getType(arr){
var result = [];
for(var i=0;i<arr.length;i++){
var tag = Object.prototype.toString.apply(arr[i]);
result.push(tag.slice(8,-1));
}
return result;
}
</script>
<script src="testData.js"></script>
</body>
</html>