mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00

This confused me every time I Ctrl+F'ed the home page for "index" and only got this cryptic statement: "Comprehensions replace (and compile into) for loops, with optional guard clauses and the value of the current array index." Now I can see how the index is used in the code.
21 lines
522 B
JavaScript
21 lines
522 B
JavaScript
var courses, dish, food, foods, index, _i, _j, _len, _len2, _len3, _ref;
|
|
|
|
_ref = ['toast', 'cheese', 'wine'];
|
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
food = _ref[_i];
|
|
eat(food);
|
|
}
|
|
|
|
courses = ['salad', 'entree', 'dessert'];
|
|
|
|
for (index = 0, _len2 = courses.length; index < _len2; index++) {
|
|
dish = courses[index];
|
|
menu(index + 1, dish);
|
|
}
|
|
|
|
foods = ['broccoli', 'spinach', 'chocolate'];
|
|
|
|
for (_j = 0, _len3 = foods.length; _j < _len3; _j++) {
|
|
food = foods[_j];
|
|
if (food !== 'chocolate') eat(food);
|
|
}
|