basarat / typescript-book

:books: The definitive guide to TypeScript and possibly the best TypeScript book :book:. Free and Open Source 🌹
https://basarat.gitbook.io/typescript/
Other
20.58k stars 2.52k forks source link

Improve code for initializing array from a function #649

Open samsamson33 opened 2 years ago

samsamson33 commented 2 years ago

Array.from() is, in my opinion at least, clearer in meaning than the spread operator with Array.prototype.map(). Also, as it does not create an intermediate array, it appears to be around twice as fast (on firefox).