Converts an array or array-like object to a new array by numeric index. Bypasses custom [Symbol.iterator] definitions to preserve indexed elements during serialization, and avoids per-element callback closures.
[Symbol.iterator]
Optional
The array or array-like object to convert
A fresh array containing the indexed elements
const copy = toArray(['a', 'b']);const fromObj = toArray({ 0: 'x', 1: 'y', length: 2 }); Copy
const copy = toArray(['a', 'b']);const fromObj = toArray({ 0: 'x', 1: 'y', length: 2 });
Converts an array or array-like object to a new array by numeric index. Bypasses custom
[Symbol.iterator]definitions to preserve indexed elements during serialization, and avoids per-element callback closures.