Skip to content

Instantly share code, notes, and snippets.

@tecfu
Last active March 18, 2016 06:43
Show Gist options
  • Save tecfu/edcda325f9529b70bada to your computer and use it in GitHub Desktop.
Save tecfu/edcda325f9529b70bada to your computer and use it in GitHub Desktop.
Javascript comprehensions workaround example. Like Python's range() function.
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