Last active
March 18, 2016 06:43
-
-
Save tecfu/edcda325f9529b70bada to your computer and use it in GitHub Desktop.
Javascript comprehensions workaround example. Like Python's range() function.
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
var a = []; | |
//Create an array of 10 numbers, spaced by 3 | |
for(i of Array(10).keys()) a.push(i*3); | |
//[ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27 ] | |
//The same but starting from 10 | |
for(i of Array(10).keys()) a.push(10 + i*3); | |
//[ 10, 13, 16, 19, 22, 25, 28, 31, 34, 37 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment