js 删除 数组重复

js删除数组重复

Array.prototype.unique = function() {
    var a = {};
    for (var i = 0; i < this.length; i++) {
        if (typeof a[this[i]] == "undefined")
            a[this[i]] = 1;
    }
    this.length = 0;
    for (var i in a)
        this[this.length] = i;
    return this;
}



原文地址:https://www.cnblogs.com/wangkangluo1/p/2349363.html