O'Reilly logo
  • Patrick S thinks this is interesting:

Iterating Through Arrays

You can iterate through an array using a for or a for/in loop. The following code illustrates iterating through each item in the array using each method:

var week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"];
for (var i=0; i<week.length; i++){
  console.log("<li>" + week[i] + "</li>");


Cover of Node.js, MongoDB, and AngularJS Web Development


iterating arrays