javascript的数组之from()

Array.from()方法从一个类似数组或可迭代对象中创建一个新的数组实例。

const arr = [1, 2, 3];

Array.from(arr); //[1, 2, 3]

 

Array.from('foo'); // ['f', 'o', 'o']

参数

第一个:接受一个类数组或可迭代对象。

第二个:新数组每个元素都会执行的回调函数

第三个:指定第二个参数的this对象

 

posted @ 2018-06-08 20:46  环球学习机  阅读(3733)  评论(0编辑  收藏  举报