You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3、Array.prototype.entries
返回一个数组迭代器(Array Iterator), that can be used to loop through the array’s keys and values. entries will return an array of arrays, where each child array is an array of [index, value].
Each time the mapping function gets called, the val argument will be undefined, as this object has no actual values, but the key argument will be 0, then 1 and so on. This lets us generate arrays of numbers, but we can also return whatever we’d like from the mapping function:
1、Array.prototype.find
快速获取到第一个匹配值
2、Array.prototype.findIndex
返回第一个匹配值的下标
3、Array.prototype.entries
返回一个数组迭代器(Array Iterator), that can be used to loop through the array’s keys and values. entries will return an array of arrays, where each child array is an array of [index, value].
We can also use the spread operator to get back an array of the entries in one go:
4、Array.from
from can also take a second argument, which is a map function to be applied to each element:
Because the method can take array like objects, we can use it to generate arrays of values too:
Each time the mapping function gets called, the val argument will be undefined, as this object has no actual values, but the key argument will be 0, then 1 and so on. This lets us generate arrays of numbers, but we can also return whatever we’d like from the mapping function:
5、Array.map
返回新的数组
原文链接
The text was updated successfully, but these errors were encountered: