方法一:

//两个for循环
Array.prototype.delRepeat1 = function () {
var r = new Array();
label: for (var i = 0, n = this.length; i < n; i++) {
for (var x = 0, y = r.length; x < y; x++) {
if (r[x] == this[i]) {
continue label;
}
}
r[r.length] = this[i];
}
return r;
}

Array.prototype.delRepeat2 = function () {
this.sort();//排序
var n = [this[0]];
for (var i = 1; i < this.length; i++) {
if (this[i] !== n[n.length - 1]) {
n.push(this[i]);
}
}
return n;
}

Array.prototype.delRepeat3 = function () {
var n = []; //一个新的临时数组
for (var i = 0; i < this.length; i++) //遍历当前数组
{
//如果当前数组的第i在临时数组已有，跳过，否则把当前项push到临时数组里
if (n.indexOf(this[i]) == -1) n.push(this[i]);
}
return n;
}

Array.prototype.delRepeat4 = function () {
var n = {}, r = []; //n为hash表，r为临时数组
for (var i = 0; i < this.length; i++) //遍历当前数组
{
if (!n[this[i]]) //如果hash表中没有当前项
{
n[this[i]] = true; //存入hash表
r.push(this[i]); //把当前数组的当前项push到临时数组里面
}
}
return r;
}

Array.prototype.delRepeat5 = function () {
var n = [this[0]]; //结果数组
for (var i = 1; i < this.length; i++) //从第二项开始遍历
{
//如果当前数组的第i项在当前数组中第一次出现的位置不是i，
//那么表示第i项是重复的，忽略掉。否则存入结果数组
if (this.indexOf(this[i]) == i) n.push(this[i]);
}
return n;
}

Array.prototype.delRepeat6 = function () {
return this.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|\$)/g, "\$1\$2\$4").replace(/,,+/g, ",").replace(/,\$/, "").split(",");
}

Array.prototype.delRepeat7 = function () {
var temp = {}, len = this.length;
for (var i = 0; i < len; i++) {
var tmp = this[i];
if (!temp.hasOwnProperty(tmp)) {//hasOwnProperty用来判断一个对象是否有你给出名称的属性或对象
temp[this[i]] = "yes";
}
}

len = 0;
var tempArr = [];
for (var i in temp) {
tempArr[len++] = i;
}
return tempArr;
}

function delRepeatExample () {
var arr = [];//测试的数组
for (var i = 0; i < 10000; i++) {
var t = parseInt(Math.random() * 1000);
arr[i] = (t.toString());
}
var s = new Date();//定义开始的时间！
var a=arr.delRepeat();

var dd = new Date() - s;//执行时间=当前时间-开始的时间
}