JS基础 - 数组 - 高级API - filter()方法

filter()方法

var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
var arr2 = arr.filter(function(value, index) {
    return index % 3 === 0 || value >= 9;
});

console.log(arr2);

猜你喜欢

转载自blog.csdn.net/weixin_37580235/article/details/80750074
今日推荐