filter数组过滤
let t=[{"name":"张三"},{"name":"李四"},{"name":"王五"},{"name":"赵六"}]; let t_filter = t.filter((item) => { if (item.name == "张三" || item.name == "李四") { debugger; return false; } else { return true } }) console.log(t,"原始数据"); console.log(t_filter,"过滤后数据");
结果:
值得注意的是filter过滤不会改变原始数组。