Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k 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 (106k 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); 

});

Related questions

0 votes
1 answer
0 votes
1 answer

Browse Categories

...