Array.from()
create Array from:
array-like objects (with a
lengthproperty and indexed elements)iterable objects (such as
MapandSet).
// ⭐️ from iterables
Array.from('foo') // [ "f", "o", "o" ]
// ⭐️ from "array-like" objects
function f() { return Array.from(arguments) }
f(1, 2, 3) // [ 1, 2, 3 ]
Array.from( // [0, 1, 2, 3, 4] ⭐️
{length: 5}, // "array-like" object
(_, i) => i
)Last updated
Was this helpful?