Return to Snippet

Revision: 59205
at August 23, 2012 23:16 by guilhermehn


Updated Code
function unique(arr, dup) {
    dup = dup ? arr.concat() : arr;
    for(var i = 0; i < dup.length; i++) if(dup.indexOf(dup[i]) < i) dup.splice(i--);
    return dup;
}

Revision: 59204
at August 23, 2012 23:01 by guilhermehn


Initial Code
function unique(arr,dup) { dup = dup ? arr.concat() : arr; for (var i=0; i < dup.length; i++) if (dup.indexOf(dup[i]) < i) dup.splice(i--); return dup; }

Initial URL

                                

Initial Description
Original by dvdrtrgn

Initial Title
Remove duplicate itens from an array

Initial Tags
javascript, array

Initial Language
JavaScript