<?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: Ndonna</title>
    <description>The latest articles on DEV Community by Ndonna (@ndonnauc).</description>
    <link>https://dev.to/ndonnauc</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%2F315261%2F0022ebe2-06a3-48b3-8fc3-b9afe8323ab6.jpg</url>
      <title>DEV Community: Ndonna</title>
      <link>https://dev.to/ndonnauc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ndonnauc"/>
    <language>en</language>
    <item>
      <title>DESTRUCTURING ARRAYS IN JS</title>
      <dc:creator>Ndonna</dc:creator>
      <pubDate>Thu, 11 Jun 2020 12:34:09 +0000</pubDate>
      <link>https://dev.to/ndonnauc/destructuring-arrays-in-js-50d2</link>
      <guid>https://dev.to/ndonnauc/destructuring-arrays-in-js-50d2</guid>
      <description>&lt;p&gt;Hi I am Ndonna Ugwuede a javaScript newbie, and as a noob in javaScript i found it hard understanding Destructuring, even after reading many materials and watching tutorial videos it was still sounding strange but thanks to Mark Zamoyta i finally got a grasp of it. &lt;/p&gt;

&lt;p&gt;Firstly, what do you need destructuring for?&lt;/p&gt;

&lt;p&gt;Destructuring gives us an avenue to name our Array/Object items as against the regular calling of array items with "arrayName[0]" or Objects with "object.key". &lt;/p&gt;

&lt;p&gt;DESTRUCTURING ARRAYS &lt;/p&gt;

&lt;p&gt;You can destructure an array using the syntax let [name1, name2, name3] = names; where names is an already existing array. Using an example we have an array named Cars with content ["Benz", "Honda", "Nissan", "Toyota", "Ford"] and we want to assign them to variables namely car1, car2, car3, car4, car5. Going the old school way we would to go through assigning each with: &lt;br&gt;
let car1 = Cars[0], car2 = Cars[1], .... etc&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FKsDtnr4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6fky39s2m5tma97nck92.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FKsDtnr4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6fky39s2m5tma97nck92.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Destructuring has brought a simpler way to do this where you can name array items where we can name our array items using: &lt;br&gt;
let [car1, car2, car3, car4, car5] = Cars;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j5xzrgKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4b3k2hel9ie1ab7ukyb7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j5xzrgKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4b3k2hel9ie1ab7ukyb7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You could even assign the remaining items into another named array using a rest operator (...), if we aren't sure of the number of items to be named. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0RIQk4R9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9klvcm1x776pxgiosd31.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0RIQk4R9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9klvcm1x776pxgiosd31.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another beauty is we could skip some items, if we are sure of what to skip, some strategic items we are sure of we could be removed by putting a comma in its place e.g we could remove our first and second item of the array using: &lt;br&gt;
let [,,car3, car4, car5] = Cars;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LRlW0t2n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6rwyv6e3osspgalq51t6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LRlW0t2n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6rwyv6e3osspgalq51t6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Destructuring also works fine with/on Objects, I'll be making another post explaining DESTRUCTURING OBJECTS IN JS, in the near future but in the meantime you could reach out to me on twitter: &lt;a href="https://twitter.com/Ndonnauc"&gt;https://twitter.com/Ndonnauc&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>100daysofcode</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
