是这样的, A.removeALL(B)这种方法, 不是angularjs的方法, 也不是原生js的方法. 并非java有的它都有.
使用原生js实现个这样的方法其实很简单.
徒手写了个js,如下:
function removeAll(array){
const _this = this;
array.forEach(function(v) {
const i = _this.indexOf(v);
i >= 0 && _this.splice(i, 1);
});
}
let a = [1,2,3,4,5,6,7,8,9,10];
let b = [1,3,5,7,9];
removeAll.call(a,b);
console.log(a); // [2, 4, 6, 8, 10]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…