Foreach loop in JavaScript

JavaScript knows two types of “foreach” loops:

  • for (idx in values) iterates over the indices of the array
  • for (val of values) iterates over the values of the array

Example:

 References

  • [1] MDN on for .. of

 

Leave a Reply

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

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box