var arr = [0, 1, 2, 2, 3, 3, 5];
var dups = arr.filter ( (v,i,a) => a.indexOf(v) < i );
console.log(dups);
[
2,
3
]
when v=2, a.indexof(2)=2,but i=3
so filter 2 to the dups
var arr = [0, 1, 2, 2, 3, 3, 5];
var dups = arr.filter ( (v,i,a) => a.indexOf(v) < i );
console.log(dups);
[
2,
3
]
when v=2, a.indexof(2)=2,but i=3
so filter 2 to the dups
For further actions, you may consider blocking this person and/or reporting abuse
pronab pal -
JetThoughts Dev -
A A -
David Jonson -
Top comments (0)