<?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: Aashritha Shiva</title>
    <description>The latest articles on DEV Community by Aashritha Shiva (@aashrithashiva29).</description>
    <link>https://dev.to/aashrithashiva29</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%2F394320%2F49b218b2-8ad7-40a8-8990-356c58b0e5b1.png</url>
      <title>DEV Community: Aashritha Shiva</title>
      <link>https://dev.to/aashrithashiva29</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aashrithashiva29"/>
    <language>en</language>
    <item>
      <title>Possible ways of Iterating ARRAYS in JavaScript</title>
      <dc:creator>Aashritha Shiva</dc:creator>
      <pubDate>Fri, 29 May 2020 10:38:39 +0000</pubDate>
      <link>https://dev.to/aashrithashiva29/possible-ways-of-iterating-arrays-in-javascript-1cgo</link>
      <guid>https://dev.to/aashrithashiva29/possible-ways-of-iterating-arrays-in-javascript-1cgo</guid>
      <description>&lt;p&gt;Arrays are used to solve most of the coding problems. So when starting with this, there raises a question for everyone i.e “What are the possible ways to iterate arrays and opting which would be the best?”. The main aim of this blog is to find the possible ways and which method performs best.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. for :
&lt;/h1&gt;

&lt;p&gt;The “for loop” is the common way of iterating an array. The syntax of for takes an initialization followed by condition and then by increment/decrement operation. The example code below depicts the usage of the “for”.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;If the condition is written as “i&amp;lt;a.length”, the for loop calculates the length of the array for every iteration and increases the time. So, calculate the length priorly and store it in a variable and make use of it everywhere. This improves the performance of the code.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. forEach :
&lt;/h1&gt;

&lt;p&gt;“forEach()” invokes the callback function, which is being given, for each element of the array. forEach works only for arrays. The example code below depicts the usage of the “forEach”.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  3. while :
&lt;/h1&gt;

&lt;p&gt;“while” is an entry-level condition checking control statement. The condition is being provided to the while loop and if the loop accepts that condition, the control enters into it and executes the statements. If the condition becomes false, the control moves out of the loop. The example code below depicts the usage of the “while”.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  4.do-while :
&lt;/h1&gt;

&lt;p&gt;The do-while loop performs exit-level condition checking. So this loop executes a block of code at least once even when the condition is false. The example code below depicts the usage of the “do-while”.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  5.for…of :
&lt;/h1&gt;

&lt;p&gt;The for…of statement is used to loop over the data structures that are iterable such as Arrays, Strings, Maps etc. It calls a custom iteration hook with instructions to execute on the value of each property of the object. The example code below depicts the usage of “for…of”.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  6.for…in :
&lt;/h1&gt;

&lt;p&gt;for…in is mostly used to iterate over the properties of an object. As for..of operates on the data items of the array directly, for…in loops through the indices of the array. So we must log “a[i]”.The for…in iteration happens in an arbitrary order. The example code below depicts the usage of “for…in”.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  7.filter :
&lt;/h1&gt;

&lt;p&gt;“filter” takes an array and filters out unwanted elements based on the condition provided. This way helps us avoiding usage of for or forEach along with conditional statements. It is an available method only for array and the first argument of that is callback. After the callback is executed, a new array is returned with the required result. The example code below depicts the usage of “filter”.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  8. map :
&lt;/h1&gt;

&lt;p&gt;There will be a condition that raises for us when we are working with arrays demanding a modification of array elements. “map” method helps us achieve that. It is an available method only for array. Similar to “filter”, map executes a callback on each element and returns a new array with the required result. The example code below depicts the usage of “map”.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now we have seen the possible ways of iterating the arrays and performing operations on the array elements. FEW THINGS TO BE NOTED…&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is most commonly suggested that “for…in” not to be used with arrays because we can’t guarantee that the iteration happens in sequence.&lt;/li&gt;
&lt;li&gt;Make better use of ES6 functions map and filter as they make our work more simpler.&lt;/li&gt;
&lt;li&gt;“map” creates a new array by transforming every element in an array individually. “filter” creates a new array by removing elements that don’t satisfy the condition.&lt;/li&gt;
&lt;li&gt;The callback function for the “map” function must have a “return” statement. However the single liner arrow functions use the implicit return but when using {}, “map” assumes it as a body and demands for a return statement.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;When an explicit return is not given, “map” returns undefined but “filter” returns an empty array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;The performance of for…of loop is great compared to for...in and forEach. If it is a casual iteration, it is mostly suggested to go for “for”.&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Make use of the above-mentioned methods depending on the situation. I hope this blog helps you better understand the ways of iterating arrays in JavaScript.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
Feel free to put your feedback. :) &lt;br&gt;&lt;/p&gt;

&lt;p&gt;Thank you guys!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Quick Self-learning tip </title>
      <dc:creator>Aashritha Shiva</dc:creator>
      <pubDate>Tue, 26 May 2020 08:55:51 +0000</pubDate>
      <link>https://dev.to/aashrithashiva29/a-quick-self-learning-tip-37mn</link>
      <guid>https://dev.to/aashrithashiva29/a-quick-self-learning-tip-37mn</guid>
      <description>&lt;p&gt;Hello Everyone&lt;/p&gt;

&lt;p&gt;This is just a random post that might help self learners. Let's look into it.&lt;/p&gt;

&lt;p&gt;Yesterday I have come across  a question " I have so many resources , I've registered courses in more than one resource and now I'm confused about which one to prefer and I feel like I'm lost and not learning anything " .&lt;/p&gt;

&lt;p&gt;This kind of questions will be common in most of them ! Even I was into this situation in some phase of my life.&lt;/p&gt;

&lt;p&gt;The best thing I want to mention about this is ... "Do not expect some course to give you entire knowledge about that language/library/framework or anything that you are learning". Instead make list of resources, compare the topics, find one good resource(based on topics it is providing/way of explanation), follow docs  simultaneously,read books and blogs . This helps you gain more knowledge in the language you are learning !!&lt;/p&gt;

&lt;p&gt;Keep going guys ! &lt;br&gt;
Thank you !&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>coding</category>
    </item>
    <item>
      <title>Is Commenting Code that necessary?</title>
      <dc:creator>Aashritha Shiva</dc:creator>
      <pubDate>Sun, 24 May 2020 16:57:18 +0000</pubDate>
      <link>https://dev.to/aashrithashiva29/is-commenting-code-that-necessary-5hd6</link>
      <guid>https://dev.to/aashrithashiva29/is-commenting-code-that-necessary-5hd6</guid>
      <description>&lt;p&gt;So We’ve seen people often suggesting to comment while coding. Let’s together find out what the comments are and how are they really helpful.&lt;/p&gt;

&lt;p&gt;“Comments” are the text that is being added to the computer programs to better understand the implementation logic.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;In technical terms, “ A comment is a programmer-readable explanation or annotation in the source code of a computer program.” (source: wiki)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--glR1PiTA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/36xlfg52wsl0qnss0sdc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--glR1PiTA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/36xlfg52wsl0qnss0sdc.jpg" alt="Code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is a phase where everyone thinks that “As I’ve written the code I can better understand it !! so what is the need of commenting? “&lt;br&gt;
Or&lt;br&gt;
“Whom do the comments in my program help? “&lt;br&gt;
Or to be simpler&lt;br&gt;
“What is the use of writing comments? “&lt;/p&gt;

&lt;p&gt;I’m gonna crack all these answers for you now…! :)&lt;/p&gt;

&lt;p&gt;For instance, you’ve put your code in an open-source platform and users try to read it. What if they couldn’t cope up with the flow?&lt;br&gt;
When we are writing smaller programs, it is okay to understand the code and logic with little hard work. But when we are trying to build larger applications where one file is linked to another or data is being rendered from other files, commenting can help you better understand the overview of code working.&lt;br&gt;
The two important scenarios where comments help are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;People who are referring to your code can easily go through the flow as the comments prevent one fight with the logic.&lt;/li&gt;
&lt;li&gt; You can understand your code when you read it after years (happens with most programmers ).&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;How should be the comments?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Try to keep them relevant.&lt;/li&gt;
&lt;li&gt;Don’t write bigger comments, keep it short and simple.&lt;/li&gt;
&lt;li&gt;Don’t use it everywhere. ( Find the toughest code lines to comment).&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;For example, we are commenting an HTML file,&lt;br&gt;
The comment should be in such a way that it should give a description (one line) about the tag and any ids or classes included in it.&lt;br&gt;
So try to comment your code so that it helps for your future reference and also to those who are willing to refer your code.&lt;br&gt;
I hope this helps you.&lt;br&gt;
Do drop your feedback :)&lt;br&gt;
Thank you guys. !&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>coding</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
