faqts : Computers : Programming : Languages : JavaScript : Language Core : Arrays

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

14 of 34 people (41%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How do I loop through an array?

Jul 12th, 2001 02:05
Jean-Bernard Valentaten, Per M Knutsen,


var loopArray = new Array
('fill', 'it', 'up', 'with', 'whatever', 'you', 'want');
function arrayLoop(index)
{
  var i = index;
  //here you do something with the Array e.g. alert it
  alert(loopArray[i]);
  if (i == loopArray.length - 1)
    i = 0;
  else
    i++;
  setTimeout("arrayLoop(" + i + ")", 5000);
}
HTH