Is it possible to map only a portion of an array? (Array.map())

前端 未结 8 977
终归单人心
终归单人心 2020-12-31 07:16

I am building a project using React.js as a front-end framework. On one particular page I am displaying a full data set to the user. I have an Array which contains this full

8条回答
  •  半阙折子戏
    2020-12-31 07:35

    Array#map iterates over all items.

    The map() method creates a new array with the results of calling a provided function on every element in this array.

    You could use Array#filter

    The filter() method creates a new array with all elements that pass the test implemented by the provided function.

    for the wanted items and then apply map for the wanted format.

提交回复
热议问题