Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Collections form an important part of almost any object-oriented programming language. They let us easily store multiple values either in a list, such as an array, or using a key/value pair, like objects in JavaScript. With objects we can represent an item, such as a book, and give it values such as a title, author, and publication date. Using an array we can then store a list of the book objects we create.
Along with collections come iterators. Iterators let us take our stored values, such as that list of books, and loop through them one at a time, allowing us to print each one to the screen, update some information on each book, or do whatever our application needs to do.
In the first half of this chapter we learn about arrays and objects in CoffeeScript. We’ll see how they map to their JavaScript counterparts. Because this is CoffeeScript, we’ll also look at some of the fun little hidden gems that are available to us with arrays and objects.