Skip to content

For each in native JavaScript

The syntax in JS for a for each loop is a bit different than in other languages (e.g. C#, Java or Python):

values = ["a", "b", "c"]
values.forEach(function(element) {
  //Log each element to console
  console.log(element);
});

(source)

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.