from
The method may be from the array into two types of objects, one is the array object type (array-like-object), one is traversable (Iterable) of objects (including the new set of data structures and ES6 Map).
An array of array-turn
|
|
The above code, querySelectorAll
the method returns an array-like objects, only the object into a real array, in order to use forEach
the method.
There are no length
objects to pass through Array.from
into the array method
|
|
from
Accept parameters
Array.from
Can accept a second parameter, the array acts like map
a method, for each element processed.
|
|
Turn an array of strings
Array.from
String to the array, return the string length. This prevents javascript
larger than uFFFF
the Unicode
characters, counted as two charactersbug
|
|
of方法
of
方法用于将一组值,转为数组
find方法
find
方法,用于找出第一个符合条件的数组成员,它的参数是一个回掉函数,找出一个返回值为true
的成员,然后返回该成员。如果没有符合条件的则返回undefined
|
|
find
回掉函数接受三个参数,分别为当前的值
、当前的位置
、原数组
findIndex方法
用法于
find
方法类似,返回第一个符合条件的数组成员的位置,没有找到的话返回-1.
|
|
find
与findIndex
都可以借助Object.is
方法做到发现数组中的NaN
,而indexOf
发现不了。
|
|
fill方法
fill()
使用一个值来填充一个数组。
|
|
The above code shows that fill
the initialization method is very convenient for an empty array. Array elements are already erased all of them. fill
You can also accept the second and third argument specifies the fill start position and an end position
|
|