修正一下,兼容testData内arr1和arr2可能为字符串的情况
function arraysSimilar(arr1, arr2){ var arr1 = typeof arr1 == 'string' ? arr1.split(',') : arr1; var arr2 = typeof arr2 == 'string' ? arr2.split(',') : arr2; if(arr1.length != arr2.length) return false; function processData(arr){ var _arr = []; for(var i = 0; i < arr.length; i++){ _arr.push(Object.prototype.toString.call(arr[i])); } return _arr.sort().join(','); } return processData(arr1) === processData(arr2); }