Array.from()

create Array from:

// ⭐️ 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