0 votes
1 view
in Web Technology by (32.5k points)

How can I loop through all the entries in an array using JavaScript?

I thought it was something like this:

forEach(instance in theArray)

Where theArray is my array, but this seems to be incorrect.

1 Answer

0 votes
by (76.8k points)

With the release of ES5 the forEach was also released so you can use forEach to loop over the array as follows:-

var abc = ["a", "b", "c"]; 

abc.forEach(function(entry) { 

console.log(entry); 

});

...