Arrayfrom
Array.from is a static method of the Array object in JavaScript. It creates a new array from an array-like or iterable object. It accepts two optional parameters: mapFn and thisArg.
If the first argument is a string, an arguments object, a NodeList, or any object with a
If a mapFn is provided, it is called for each element with arguments (value, index, array) and
- Array.from('hello') yields ['h','e','l','l','o'].
- Array.from({length: 3}, (_, i) => i) yields [0, 1, 2].
- Array.from(document.querySelectorAll('div')) yields an array of the selected elements (in environments with a DOM).
If the provided object is neither iterable nor array-like, Array.from throws a TypeError. It is widely supported