Created
January 30, 2016 17:52
-
-
Save goldhand/83f5bcc817f5e7d1783b to your computer and use it in GitHub Desktop.
How to create an array in javascript similar to python's range function
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
Array.from(Array(5).keys()); | |
// -> [0, 1, 2, 3, 4] | |
// Array(5) | |
// -> [ , , , , ] | |
// the values are empty but the keys will increment so we create another array from this array's keys. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment