Javascript Array unique5()

Description

Javascript Array unique5()


Array.prototype.unique5 = function() {
    var res = [], hash = {};
    for(var i=0, elem; (elem = this[i]) != null; i++)  {
        if (!hash[elem])
        {/*www.j av  a 2s  . co  m*/
            res.push(elem);
            hash[elem] = true;
        }
    }
    return res;
}



PreviousNext

Related