function arraysSimilar(arr1, arr2) { let result = false; if (arr1 !== null && arr1 !== undefined && arr1 instanceof Array && arr2 instanceof Array && arr1.length === arr2.length) { let arrt1 = arr1.map(i => Object.prototype.toString.apply(i)).sort(); let arrt2 = arr2.map(i => Object.prototype.toString.apply(i)).sort(); if (JSON.stringify(arrt1) == JSON.stringify(arrt2)) { result = true; } } return result; }
<p>慢慢优化就好</p>