js数组去重

var 数组 = [4,5,46,4,8,9];

Array.prototype.distinct = function(){
    var arr = this,
    result = [],
    i,j,
    len = arr.length;
    for(i = 0; i < len; i++){
        for(j = i + 1; j < len; j++){
            if(arr[i] === arr[j]){
                j = ++i;
            }
        }
        result.push(arr[i]);
    }
    return result;
}

数组.distinct()
原文地址:https://www.cnblogs.com/rockyan/p/9516341.html