数组的各种处理场景

1. Filter

    基础定义: 菜鸟(https://www.runoob.com/jsref/jsref-filter.html),mdn(https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)

 用法示例: https://www.jianshu.com/p/b074d106bd07

 筛选数组arr中所有大于4的元素并返回该数组 

let arr = [1, 3, 5, 8]
let arrFilter = arr.filter(ele => ele > 4) 
console.log(arrFilter) // [5, 8] 
posted @ 2022-06-30 17:29  宫圆薰  阅读(22)  评论(0编辑  收藏  举报