Javascript onclick shows last element of array with for loop

后端 未结 3 1245
粉色の甜心
粉色の甜心 2021-01-14 13:21

I have little problem. I am working with one companys API\'s. I request for activities and they return me array of activities. Here is part of code.

client.r         


        
3条回答
  •  醉话见心
    2021-01-14 13:47

    If you don't care about IE8- then ES5 already solves this issue with forEach:

    activities.forEach(function(v, i){
      // now 'i' will work anywhere within this scope
    });
    

提交回复
热议问题