var arr = [6,2,5,4,2];
     arr.forEach(function(correntvalue,index,array){
        //  console.log(correntvalue);   //correntvalue是当前项
        //  console.log(index); //index是当前项的索引
        //  console.log(array); //array是调用forEach的数组
    })

forEach是ES5新增的方法,有三个返回值

第一个返回值是当前项    correntvalue

console.log(correntvalue)

forEach()

 

第二个返回值是当前项的索引    index

console.log(index)

forEach()

 

第三个返回值是调用forEach的数组  array

console.log(array)

forEach()

 


 
                    
            
                

相关文章:

  • 2021-07-11
  • 2021-06-30
  • 2021-12-18
  • 2021-06-10
  • 2021-09-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2021-12-21
  • 2021-12-30
  • 2021-06-28
相关资源
相似解决方案