Last active
April 14, 2021 20:28
-
-
Save esundahl/fb617c634005ac1dc8c0a57bbc58c82e to your computer and use it in GitHub Desktop.
Create a new array with values 0-99
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://itnext.io/heres-why-mapping-a-constructed-array-doesn-t-work-in-javascript-f1195138615a | |
Array(100).map((_, i) => i) // Won't work | |
[...Array(100)].map((_, i) => i) // Will work | |
const range = (start, end) => Array.from({ length: end - start + 1 }, (x, i) => i + start) | |
range(0, 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment