hi我会努力的
2020-04-27 21:50
<!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 result1 = [];
var result2 = [];
for(var i=0;i<arr1.length;i++){
var a =Object.prototype.toString.apply(arr1[i]);
var b =Object.prototype.toString.apply(arr2[i]);
result1.push(a.slice(8,-1));
result2.push(b.slice(8,-1));
}
var a=result1.sort();
var b=result2.sort();
for(var i=0;i<a.length;i++){
if(a[i] !== b[i]){
return false;
}
}
}else{
return false;
}
return true;
}else{
return false;
}
}
</script>
<script src="./js/testData.js"></script>
</body>
</html>
漂亮!!!
JavaScript深入浅出
281111 学习 · 1020 问题
相似问题