instance method Enumerable#each
Enumerable#each(iterator[, context]) → Enumerable
Function) – A
Functionthat expects an item in the collection as the first argument and a numerical index as the second.
Object) – The scope in which to call
iterator. Affects what the keyword
iterator for each item in the collection.
['one', 'two', 'three'].each(alert); // Alerts "one", then alerts "two", then alerts "three"
Most of the common use cases for
each are already available pre-coded
as other methods on
Enumerable. Whether you want to find the first
matching item in an enumeration, or transform it, or determine whether it
has any (or all) values matching a particular condition,
has a method to do that for you.