需求:有一个数组,需要找出比旧数组多的数据,删除的数据
getNewValues(arr1, arr2) {
let res = [];
arr2.forEach((item, idx) => {
if (arr1.indexOf(item) == -1) res.push(item);
});
return res;
},
调用
// 新增的列表
let arr1 = _this.getNewValues(_this.oldList, arr);
// 删除的列表
let arr2 = _this.getNewValues(arr, _this.oldList);
博客提出一个需求,即针对一个数组,要找出相较于旧数组新增的数据以及被删除的数据,涉及数组数据对比操作,属于信息技术领域。
1062

被折叠的 条评论
为什么被折叠?



