数组对象的filter⽅法数组对象的filter⽅法
const array1 =new Array(1,2,3,4);
const array2 = array1.filter(function(value, index, self){
return value >2?true:false;
}, thisObj)
// filter() ⽅法的参数:
// callback:回调⽅法,从数组中每遍历出⼀个元素就调⽤⼀次该⽅法
// callback 函数的形参:
// value: 当前遍历出的元素
// index: 当前遍历出的元素对应的索引
filter过滤对象数组
// self: 数组本⾝
/
/ thisObj:我们可以⽤过该参数指定回到函数中 this 的指向。
console.log(array2)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。