更新时间:2022-11-18 22:43:36
您可以使用 filter()
函数的 this
参数来避免存储过滤器数组在一个全局变量中.
You can use the this
parameter of the filter()
function to avoid to store your filter array in a global variable.
var filtered = [1, 2, 3, 4].filter(
function(e) {
return this.indexOf(e) < 0;
},
[2, 4]
);
console.log(filtered);