📌  相关文章
📜  indexof javascript 重复数组 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:15.308000             🧑  作者: Mango

代码示例1
Array.prototype.getDuplicates = function () {
    var duplicates = {};
    for (var i = 0; i < this.length; i++) {
        if(duplicates.hasOwnProperty(this[i])) {
            duplicates[this[i]].push(i);
        } else if (this.lastIndexOf(this[i]) !== i) {
            duplicates[this[i]] = [i];
        }
    }

    return duplicates;
};