Created
April 22, 2014 15:43
-
-
Save lmartins/11184176 to your computer and use it in GitHub Desktop.
CoffeeScript For loops
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
# Reference: http://discontinuously.com/2012/05/iteration-in-coffeescript/ | |
for element in arr | |
console.log element | |
# code here | |
# Expose the index in an Array Comprehension | |
for element, index in arr | |
console.log element | |
# code here | |
for i in [0..n] by 1 | |
console.log i | |
# code here | |
for i in [0..n] by 1 | |
console.log i | |
# code here | |
# Reverse interaction | |
for i in arr by -1 | |
console.log i | |
# code here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment