How to write for
loop in CoffeeScript.
for loop of array
In Ruby, it is written as items.each
.
1 2 3 4 |
arr = ['a', 'b', 'c'] for item in arr alert item |
for loop of array with index
In Ruby, it is written as items.each_with_index
.
1 2 3 4 5 |
arr = ['a', 'b', 'c'] for item, index in arr alert index alert item |