js 数组去重

        //数组去重
        Array.prototype.unique5 = function() {
            var res = [], hash = {};
            for(var i=0, elem; (elem = this[i]) != null; i++)  {
                if (!hash[elem]) {
                    res.push(elem);
                    hash[elem] = true;
                }
            }
            return res;
        }
        var arr=[1,2,3,4,5,6,7,2,3,4,2,5];
        alert(arr.unique5());
原文地址:https://www.cnblogs.com/fan-fan/p/4063130.html