Using Array.from to Create Arrays from Array-like Objects in Javascript


Convert array-like objects (e.g., NodeList) or iterables (e.g., Set) into arrays.

Source Code

let arrayLike = {0: 'a', 1: 'b', length: 2};
let arr = Array.from(arrayLike);
console.log(arr);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments