遍历数组的方法:every,some,forEach,map,filter

首先我们来定义一个数组let arr = [1,2,3,4,5]

下面我们挨个来看一下这些方法

every:

  数组返回false则停止循环

  遍历数组的方法

some:

  数组返回true则停止循环

  遍历数组的方法

forEach:

  循环不能停止

  遍历数组的方法

map:

  返回一个经过处理的新数组,不会破坏原来的数组

  遍历数组的方法

filter:

  返回为筛选结果为true 的项组成的新数组

  遍历数组的方法

目前的话遍历数组有以上几个API,仅此记录一下

 

相关文章:

  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2020-01-16
  • 2022-02-07
  • 2022-02-07
  • 2022-02-07
猜你喜欢
  • 2022-02-07
  • 2022-02-07
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
相关资源
相似解决方案