<?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: Dev Duckling</title>
    <description>The latest articles on DEV Community by Dev Duckling (@dev_duckling).</description>
    <link>https://dev.to/dev_duckling</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%2F1067736%2Fb658bb62-c87b-463d-b2b0-1974c58545fb.png</url>
      <title>DEV Community: Dev Duckling</title>
      <link>https://dev.to/dev_duckling</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dev_duckling"/>
    <language>en</language>
    <item>
      <title>Loop over iterable and object with for..in and for..of</title>
      <dc:creator>Dev Duckling</dc:creator>
      <pubDate>Sun, 30 Apr 2023 08:42:48 +0000</pubDate>
      <link>https://dev.to/dev_duckling/loop-over-iterable-and-object-with-forin-and-forof-3k51</link>
      <guid>https://dev.to/dev_duckling/loop-over-iterable-and-object-with-forin-and-forof-3k51</guid>
      <description>&lt;p&gt;In the world of loops, there are &lt;code&gt;for..of&lt;/code&gt; and &lt;code&gt;for..in&lt;/code&gt; statements that I'm going to discuss.&lt;br&gt;
&lt;strong&gt;for..of is mostly used to loop over arrays, strings, map,..etc.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax:
for(items of array){
console.log(items);
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's understand &lt;code&gt;for..of&lt;/code&gt;&lt;br&gt;
I used names from anime Demon Slayer in below examples. This is my first time embedding pen into blog and it is not showing console, meh. &lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/dev_duckling/embed/vYVJRmJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
So if you look at the code I have made an array named Japan just for making code more readable. Goal is to access the hashiras from &lt;em&gt;nested array&lt;/em&gt;. For loop can be used but it is not readable like &lt;code&gt;for..of&lt;/code&gt;.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;for..in&lt;/code&gt; is used to loop over objects&lt;/strong&gt;. You can use &lt;code&gt;for..of&lt;/code&gt; too with slight adjustment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax:
for(key in object){
console.log(key);
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/dev_duckling/embed/abRyYQB?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Have a look at the code maybe visit pen if possible as console is not showing up. In the above pen I have made &lt;code&gt;object demonSlayer&lt;/code&gt;. Goal is to use &lt;code&gt;for..in&lt;/code&gt; and get key and value from the object, which is in the console.&lt;/p&gt;

&lt;p&gt;You cannot iterate over object as for..of won't work but it is possible to select object's key or value and iterate over them by method &lt;code&gt;Object.value&lt;/code&gt; and &lt;code&gt;Object.key&lt;/code&gt;, fork above pen and try below code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for(hashirasElements of Object.keys(demonSlayer)){
console.log(hashirasElements);
}

for(hashirasNames of Object.values(demonSlayer)){
console.log(hashirasNames);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code would give you keys and values from our object using &lt;code&gt;for..of&lt;/code&gt;. &lt;br&gt;
That's it! Thanks for reading this blog!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>When to use forward slash in file path?</title>
      <dc:creator>Dev Duckling</dc:creator>
      <pubDate>Wed, 19 Apr 2023 13:23:21 +0000</pubDate>
      <link>https://dev.to/dev_duckling/when-to-use-forward-slash-in-file-path-2h9d</link>
      <guid>https://dev.to/dev_duckling/when-to-use-forward-slash-in-file-path-2h9d</guid>
      <description>&lt;p&gt;&lt;em&gt;You might ask, Why am I writing this blog?&lt;br&gt;
Because I recently struggled for like hours. While building my &lt;a href="https://github.com/DevDuckling/Capstone-Project-2"&gt;capstone project 2&lt;/a&gt;, everything was going fine locally but when I merged my branch to main and checked site on Github pages then nightmare began. My responsive web app suddenly became static web app(links were not working, image were broken and on clicking DevDuckling it was showing '404') I messed up in file paths of links and images&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I will quickly explain when you do not need and need to use &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;../&lt;/code&gt; &lt;br&gt;
In below will be the example code, I have used my favorite anime characters as file names.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uCBC0H6K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5w6dom8q15o5vj11aapl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uCBC0H6K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5w6dom8q15o5vj11aapl.jpg" alt="files" width="252" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So Makima wants to have Naruto's picture in her file. She would look for path which is above current folder. Then she might use &lt;code&gt;../&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;section&amp;gt;
&amp;lt;h1&amp;gt;../ means file is present in (one level above or above current folder)&amp;lt;/h1&amp;gt;
&amp;lt;img src="../naruto.jpg" alt="naruto"&amp;gt;
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Makima wants to have Jiraiya's picture in her file. She would look for path which is on root file(top level). Then she might use &lt;code&gt;/&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;section&amp;gt;
&amp;lt;h1&amp;gt;/ is top most level that is root file&amp;lt;/h1&amp;gt;
&amp;lt;img src="/jiraiya.jpg" alt="jiraiya"&amp;gt;
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In VS code press &lt;code&gt;ctrl + space&lt;/code&gt; key gives you suggestions that is helpful. &lt;/p&gt;

&lt;p&gt;Thank-you for reading this blog! I will try to write next blog soon and forgot to mention it was my first blog to dev.to haha. If anyone has suggestions, happy to apply on next blog! As every famous creator says react, comment, share and follow. Happy codding!&lt;/p&gt;

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