Join Joe Marini for an in-depth discussion in this video Iterating over collections, part of Learning Underscore.js.
Let's start by seeing how Underscore makes it…easier to iterate or loop over sets of data.…So here in Aptana Studio, if you have the Start page open, go ahead and close it.…And I'm going to open up my example snippets and…scroll down here to the collections area in chapter two.…And under chapter 2, I'm going to open up the iterating_start file.…Now here in this file you can…see that already including the _js script as well as…the sample data that we're going to be working on.…
And down here in the HTML code I've got an H3, which has the ID of numstudents.…And I've got a div with an ID of container.…And so we're going to use these in this example.…I'm also adding an event listener onto the window object.…And it's going to listen for the load event.…And that's…where we're going to execute our test code.…So over here in the snippets I'm going to copy these tree lines right here.…And we're going to start off simply just by…using the size property to get the number…of elements in the data list, and I'm…going to Paste that into here and I'm going to Save.…
- Understanding what Underscore.js is and does
- Installing Underscore.js
- Sorting, grouping, and filtering data sets
- Extracting information about arrays and objects
- Using templates to format data