Created
December 10, 2021 05:16
-
-
Save NaClYen/a314215cbcb02a7a562a68f8b7d988c0 to your computer and use it in GitHub Desktop.
javascript create array without for-loop
This file contains hidden or 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
// [1, 1, 1, 1, 1] | |
[...new Array(5)].map(() => 1) | |
// [0, 1, 2, 3, 4] | |
[...new Array(5)].map((_, index) => index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment