O'Reilly logo

CoffeeScript Application Development Cookbook by Mike Hatfield

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with arrays

Our applications will almost always make use of data and in some cases a lot of data. In this section, we will investigate some useful ways to work with collections of data using CoffeeScript and its list comprehension feature and various JavaScript methods made available on the array object.

Iterating over arrays

CoffeeScript provides convenient operators to iterate through collections of data by using loops and comprehensions.

Getting ready

For our example, we will be working with the following array of employee objects:

employees = [ { id: 10, firstName: 'Tracy', lastName: 'Ouellette', salesYtd: 22246 } { id: 2, firstName: 'Chris', lastName: 'Daniel', salesYtd: 3876 } { id: 3, firstName: 'Jason', lastName: 'Alexander', salesYtd: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required