测试通过了
/*
* param1 Array
* param2 Array
* return true or false
*/
function arraysSimilar(arr1, arr2) {
if (
Object.prototype.toString.apply(arr1) === '[object Array]' &&
Object.prototype.toString.apply(arr2) === '[object Array]' &&
arr1.length === arr2.length
) {
var arr_1 = [];
var arr_2 = [];
for (var i = 0; i < arr1.length; i++) {
arr_1[i] = Object.prototype.toString.apply(arr1[i]);
arr_2[i] = Object.prototype.toString.apply(arr2[i]);
}
arr_1 = arr_1.sort();
arr_2 = arr_2.sort();
if (JSON.stringify(arr_1) === JSON.stringify(arr_2)) {
return true;
} else {
return false;
}
} else {
return false;
}
}