javascript中map((k,i))的k和i分别代表什么意思?

想生成一个1,100的Array

  arr=[...Array(100)].map((k,i)=>i+1);
       console.log(arr);

image.png
问题:
(k,i)中的k和i分别代表什么意思?

阅读 1.6k
1 个回答

Array.prototype.map

map(function(element, index) { /* ... */ })

callbackFn
Function that is called for every element of arr. Each time callbackFn executes, the returned value is added to newArray.

The callbackFn function accepts the following arguments:

  • element
    The current element being processed in the array.
  • index
    The index of the current element being processed in the array.
  • array
    The array map was called upon.

....

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题