<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Todd Motto™</title>
    <description>The latest articles on DEV Community by Todd Motto™ (@toddmotto).</description>
    <link>https://dev.to/toddmotto</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F360758%2F855d8552-ef3a-469b-aa19-b1b27109ff6d.jpg</url>
      <title>DEV Community: Todd Motto™</title>
      <link>https://dev.to/toddmotto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/toddmotto"/>
    <language>en</language>
    <item>
      <title>Exploring Array ForEach in JavaScript</title>
      <dc:creator>Todd Motto™</dc:creator>
      <pubDate>Sat, 04 Apr 2020 16:31:59 +0000</pubDate>
      <link>https://dev.to/ultimatecourses/exploring-array-foreach-in-javascript-1mp6</link>
      <guid>https://dev.to/ultimatecourses/exploring-array-foreach-in-javascript-1mp6</guid>
      <description>&lt;h3&gt;
  
  
  What is Array ForEach?
&lt;/h3&gt;

&lt;p&gt;Array ForEach is a method that exists on the &lt;code&gt;Array.prototype&lt;/code&gt; that was introduced in ECMAScript 5 (ES5) and is supported in all modern browsers.&lt;/p&gt;

&lt;p&gt;Array ForEach is the entry-level loop tool that will iterate over your array and pass you each value (and its index). You could render the data to the DOM for example. ForEach, unlike other array methods, does not return any value.&lt;/p&gt;

&lt;p&gt;Think of Array ForEach as: &lt;em&gt;"Give me my array values one-by-one so I can do something with them!"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here's the &lt;em&gt;syntax&lt;/em&gt; for Array ForEach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{...},&lt;/span&gt; &lt;span class="nx"&gt;thisArg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ForEach is also considered a "modern for...in loop" replacement, despite behaving differently and having less flexibility.&lt;/p&gt;

&lt;p&gt;ForEach doesn't allow us to &lt;code&gt;break&lt;/code&gt; the loop or even loop backwards, which may be a common scenario you'll run into - so it's certainly not a flat-out replacement. However, it's a pretty standard approach nowadays.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Read my full article on &lt;a href="https://ultimatecourses.com/blog/array-foreach-javascript" rel="noopener noreferrer"&gt;Ultimate Courses blog&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
  </channel>
</rss>
