二维数组转一维数组、对象数组互斥去重

二维数组转一维数组:

//二维数组转一维数组
function flatten(arr) { return [].concat(...arr.map(x => Array.isArray(x) ? flatten(x) : x)) }

对象数组互斥去重:

//对象数组互斥去重
function getArrDifference(arr1, arr2) {
    for (let i in this.arr1) {
        for (let k in this.arr2) {
            if (this.arr1[i].perName == this.arr2[k].perName) {
                this.arr2.splice(k, 1)
            }
        }
    }
}

 

posted on 2021-08-23 14:58  fox_charon  阅读(144)  评论(0编辑  收藏  举报

导航