Skip to content

数组对象去重 #12

@arcsin1

Description

@arcsin1
Array.prototype.quc = function() {
    var res = [];
    var jso = {};
    for (var i = 0; i < this.length; i++) {
        if (!jso[JSON.stringify(this[i])]) {
            res.push(this[i]);
            jso[JSON.stringify(this[i])] = 1;
        };
    }
    return res;
}
const song = [
         {1:"羽根"},
         {1:"羽根"},
         {2:"晴天"},
         
     ]
    song.quc()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions