The particularity of map() and forEach() : <p>What is the particularity (specificity) of map() vs forEach in JavaScript ?</p>

<p>They work fine identically !</p>

<pre><code> &lt;script type="text/javascript"&gt; "use strict";
   const array1 = [12, 3, 7];
   const array2 = [];

   const dispEls=(el, idx, array1) =&gt;
       array2.push("exp (a[" + idx+ "] = "+el+") = "+
       Math.exp(el).toFixed(2));

   array2.push("===== FOREACH");
   array1.forEach(dispEls);
   array2.push("===== MAP");
   array1.map(dispEls);

   console.dir(array2)
 /*[…]
 0: "===== FOREACH"
 1: "exp (a[0] = 12) = 162754.79"
 2: "exp (a[1] = 3) = 20.09"
 3: "exp (a[2] = 7) = 1096.63"
 4: "===== MAP"
 5: "exp (a[0] = 12) = 162754.79"
 6: "exp (a[1] = 3) = 20.09"
 7: "exp (a[2] = 7) = 1096.63"
 length: 8      */
 &lt;/script&gt;
</code></pre>
