JS中如何比较两个数组,取得数组二相对于数组一新增和去除的元素


//数组二相对于数组一所新增的数据
function add_msg(a,b){
    return a.filter(function(i){
        return b.indexOf(i) === -1
    })
}

//数组二相对于数组一所删除的数据
function delete_msg(a,b){
    return b.filter(function(i){
        return a.indexOf(i) === -1
    })
}

  

原文地址:https://www.cnblogs.com/dreamstartplace/p/10825057.html