Array.from()

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

1 console.log(Array.from('foo'));
2 // expected output: Array ["f", "o", "o"]
3 
4 console.log(Array.from([1, 2, 3], x => x + x));
5 // expected output: Array [2, 4, 6]

 

posted @ 2018-07-09 10:29  前端极客  阅读(172)  评论(0)    收藏  举报