Posted over 6 years ago. Visible to the public.

Looping through iterators in Coffeescript

Some modern Javascript APIs return iterators Archive instead of arrays.

In plain Javascript you can loop through an iterator using
for...of Archive :

var iterator = ...; for (var value of iterator) { console.log(value); }

While there is a for...of construct in Coffeescript, it iterates through property/value pairs Archive and cannot be used to access iterable objects.

To iterate through an iterator in Coffeescript you need to do something like this:

iterator = ...; while (entry = && !entry.done console.log(entry.value)

The parentheses in the while cannot be omitted.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for unsupported versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2).

Owner of this card:

Henning Koch
Last edit:
about 4 years ago
by Henning Koch
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more