toArray
Converts a ArrayLike
to an array.
Use spread operator inside new array to convert a arrayLike
to an array.
typescript
const toArray = <T = any>(arrLike: Iterable<T>) => [...arrLike];
typescript
toArray(document.childNodes); // [ <!DOCTYPE html>, html ]
// array like string
const caps = (x: string) => x.toUpperCase();
toArray("caps").map(caps); // ["C", "A", "P", "S"]