1 function unique(arr) { 2 var result = [], isRepeated; 3 for (var i = 0, len = arr.length; i < len; i++) { 4 isRepeated = false; 5 for (var j = 0, len = result.length; j < len; j++) { 6 if (arr[i] == result[j]) { 7 isRepeated = true; 8 break; 9 } 10 } 11 if (!isRepeated) { 12 result.push(arr[i]); 13 } 14 } 15 return result; 16 }
2、