测试通过,代码附上
function arraysSimilar(arr1, arr2) {
let t = true;
if (arr1 instanceof Array && arr2 instanceof Array ) {
if(arr1.length == arr2.length){
let a = [],
b = [];
for (let i = 0; i < arr1.length; i++) {
a.push(Object.prototype.toString.call(arr1[i]).slice(8, -1));
b.push(Object.prototype.toString.call(arr2[i]).slice(8, -1))
}
a.sort();
b.sort();
for (let j = 0; j < a.length; j++) {
if (a[j] != b[j]) {
t = false;
return false
}
}
}else t=false;
}else t=false;
return t
}