数组去重复
做一个新数组,重复的不加入
<script type="text/javascript"> Array.prototype.delrepeat = function() { var arr = this; var _arr = new Array(); for (var i in arr) { if (i == 'delrepeat') continue; if (_arr.length == 0) _arr.push(arr[i]); for (var j = 0; j < _arr.length; j++) { if (arr[i] == _arr[j]) { break; } if (j > _arr.length - 2) _arr.push(arr[i]); } } return _arr; } alert([1, 1, 7, ,9,1, 2, 2, 3, 4, 5,9, 5].delrepeat()); </script>