vis6xg
Last Updated: February 25, 2016
·
103
· gnclmorais
C740358b2cce341557a23ffb981aacf2

Simplest ‘removeDuplicates’ in JavaScript Arrays

Other question I’ve found a lot in job interview questions, and this is the simplest implementation I’ve found:

[…].filter(function (val, idx, arr) {
    var firstIdx = arr.indexOf(val);
    return (idx === firstIdx) || (firstIdx === arr.lastIndexOf(val));
});
Say Thanks
Respond