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]

猜你喜欢

转载自www.cnblogs.com/yangguoe/p/9282562.html