<?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: Dennis Mathenge</title>
    <description>The latest articles on DEV Community by Dennis Mathenge (@creativehubspace).</description>
    <link>https://dev.to/creativehubspace</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%2F173797%2F6e5fdfe6-9107-43fa-983d-8a8de7c145a2.jpg</url>
      <title>DEV Community: Dennis Mathenge</title>
      <link>https://dev.to/creativehubspace</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/creativehubspace"/>
    <language>en</language>
    <item>
      <title>#Javascript: Using the Array.prototype.map() function.</title>
      <dc:creator>Dennis Mathenge</dc:creator>
      <pubDate>Tue, 19 Nov 2019 16:18:02 +0000</pubDate>
      <link>https://dev.to/creativehubspace/javascript-use-the-array-prototype-map-function-5g3i</link>
      <guid>https://dev.to/creativehubspace/javascript-use-the-array-prototype-map-function-5g3i</guid>
      <description>&lt;p&gt;When working with JavaScript arrays, you might want to create a new array with the results of calling a provided function on every element in the previous/original array.&lt;/p&gt;

&lt;p&gt;JavaScript has a very nifty function called &lt;strong&gt;Array.prototype.map()&lt;/strong&gt; that you can use to do this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Array.prototype.map()&lt;/strong&gt; accepts a &lt;strong&gt;callback function&lt;/strong&gt; as a parameter.&lt;/p&gt;

&lt;p&gt;The callback function produces an element of the new Array and takes &lt;strong&gt;three&lt;/strong&gt; arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;currentValue - This is the current element being processed in the array.&lt;/li&gt;
&lt;li&gt;index (&lt;em&gt;optional&lt;/em&gt;) - This is the index of the current element being processed in the array.&lt;/li&gt;
&lt;li&gt;array (&lt;em&gt;optional&lt;/em&gt;) - The original array that &lt;strong&gt;map&lt;/strong&gt; was called upon.&lt;/li&gt;
&lt;li&gt;thisArg (&lt;em&gt;optional&lt;/em&gt;) - Value that you can use as &lt;strong&gt;this&lt;/strong&gt; when executing the &lt;strong&gt;callback&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example usage:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mike&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;john&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;anne&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;namesUppercase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;namesUppercase&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;namesUppercase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MIKE&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JOHN&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ANNE&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
