showing results for - "indexof javascript duplicate arrays"
Jona
06 Nov 2020
1Array.prototype.getDuplicates = function () {
2    var duplicates = {};
3    for (var i = 0; i < this.length; i++) {
4        if(duplicates.hasOwnProperty(this[i])) {
5            duplicates[this[i]].push(i);
6        } else if (this.lastIndexOf(this[i]) !== i) {
7            duplicates[this[i]] = [i];
8        }
9    }
10
11    return duplicates;
12};