<?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: Abddelrahman Saad</title>
    <description>The latest articles on DEV Community by Abddelrahman Saad (@abdelrahman).</description>
    <link>https://dev.to/abdelrahman</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%2F336097%2Ff4099bc2-7264-4520-8a21-f8ac59a9ed6c.jpg</url>
      <title>DEV Community: Abddelrahman Saad</title>
      <link>https://dev.to/abdelrahman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdelrahman"/>
    <language>en</language>
    <item>
      <title>Accessibility in Front-end</title>
      <dc:creator>Abddelrahman Saad</dc:creator>
      <pubDate>Wed, 31 Aug 2022 18:18:20 +0000</pubDate>
      <link>https://dev.to/abdelrahman/accessibility-in-front-end-4mbf</link>
      <guid>https://dev.to/abdelrahman/accessibility-in-front-end-4mbf</guid>
      <description>&lt;p&gt;One of the skills that people are not interested in, and I personally did not give it the utmost importance.&lt;/p&gt;

&lt;p&gt;I was talking to one of my colleagues at the office and I asked him from his point of view, what are the skills that distinguish one person from the other?&lt;/p&gt;

&lt;p&gt;In the midst of a lot of talks, he said the Accessibility, at the time, frankly, I was not interested in it&lt;/p&gt;

&lt;p&gt;Let me explain, the Accessibility in Front-end is how I can control the components through any external device, such as the mouse, the keyboard, or maybe a tablet pin or headphones.&lt;/p&gt;

&lt;p&gt;and guess what maybe from voice recognition&lt;/p&gt;

&lt;p&gt;Ask yourself how to make the components easily accessible for any user, from any device the user can use, and how to make it easier for him to use it.&lt;/p&gt;

&lt;p&gt;For example, if he eats and wants to move through the keyboard, how to understand which part he wants to go to it first? &lt;/p&gt;

&lt;p&gt;How do I make this part accessible through the keyboard; because there are tags, the attribute tabindex must be entered, also sometimes it is necessary to put a keypress event for example.&lt;/p&gt;

&lt;p&gt;Suppose he is blind!! Shouldn't we make him able to use the site?&lt;/p&gt;

&lt;p&gt;maybe we can add voice recognition to grasp what he wants.&lt;/p&gt;

&lt;p&gt;there are a lot of examples but I'll leave it to your imagination ;)&lt;/p&gt;

&lt;p&gt;these details distinguish one developer from another, however, it adds fun to the work.&lt;/p&gt;

&lt;p&gt;Have a productive day ❤️&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
      <category>vue</category>
    </item>
    <item>
      <title>How to use GitHub as a team member.</title>
      <dc:creator>Abddelrahman Saad</dc:creator>
      <pubDate>Tue, 14 Sep 2021 15:20:39 +0000</pubDate>
      <link>https://dev.to/abdelrahman/how-to-use-github-as-a-team-member-3114</link>
      <guid>https://dev.to/abdelrahman/how-to-use-github-as-a-team-member-3114</guid>
      <description>&lt;p&gt;One of the most essential tool you will definitely work with as a developer is GitHub.&lt;/p&gt;

&lt;p&gt;Because there's so much interesting stuff GitHub provides to us,&lt;br&gt;
today I'll explain to you how it looks like to working with a team on a project on GitHub, I'll tell you what you can do because i was in your shoes before and struggled to understand what should i do exactly.&lt;/p&gt;

&lt;p&gt;I assume that you know what is Git and GitHub because today i won't explain them, I'll be more focused on how to use it with your team.&lt;/p&gt;

&lt;p&gt;Great, let get the ball rolling.&lt;/p&gt;

&lt;p&gt;By and large you probably have a tasks you have to implement,&lt;br&gt;
so the first thing you need to do is creating a new branch for the task with convenient name.&lt;br&gt;
most of the time it will be the type of improvement you will do in this branch (i.e. Fix, Feat, Bug,) followed by the name of the feature you going to develop.&lt;/p&gt;

&lt;p&gt;Suppose that you have a new feature to implement is about building user login functionality so we can name the branch to be something like that:&lt;/p&gt;

&lt;p&gt;Feat/login&lt;/p&gt;

&lt;p&gt;"Feat" is a shortcut for Feature and followed by the name of the feature, you should be descriptive and following the best practice.&lt;/p&gt;

&lt;p&gt;﻿﻿﻿﻿﻿﻿&lt;br&gt;
let's go to the next step.&lt;/p&gt;

&lt;p&gt;After creating the branch locally and on GitHub then you need to checkout to the branch ( switch to the new branch ), with this command " git checkout Feat/login ".&lt;br&gt;
have you switched?&lt;/p&gt;

&lt;p&gt;No! don't panic this usually happens, sometimes the branch does not appear but you can write this command "git fetch" to force git look for changes then write this command "git branch -a" to see if appeared in branches list.&lt;/p&gt;

&lt;p&gt;Now checkout again you will be switched.&lt;/p&gt;

&lt;p&gt;After that you have to pull in the original code from the master branch to the new branch and that's because if there's another team member who pushed a new improvement to the master you can get it to avoid conflict. if you didn't do that you will be prone to conflicts and bugs, i warned you.&lt;/p&gt;

&lt;p&gt;This is awesome, now you are totally ready to start coding.&lt;/p&gt;

&lt;p&gt;Have you finished your task? Really? I'm surprised at how active you are.&lt;/p&gt;

&lt;p&gt;Now it's the time to push our code to our "Feat/Login" branch.&lt;/p&gt;

&lt;p&gt;Write the " add . " command and after that, you have to commit the changes.&lt;br&gt;
But pay attention to your commit messages, choose the right words that describe what changed with this commit especially if you make many commit "Micro-commits",&lt;/p&gt;

&lt;p&gt;to let your team leader or anyone who is looking at your code knows what you changed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Micro-Commits is one of the strategies you could use to give thorough steps about changes, such as " Form Created ", " CSS Applied ", and so on.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Wait a second don't push it yet, please pull the code again from the master "git pull origin master", you don't know if there's anything changed while you were implementing your login feature, right? especially if the task took a lot of time and your team is big.&lt;/p&gt;

&lt;p&gt;Have you pulled the code? now you're ready to push your code to the new branch you created " git push origin Feat/login "&lt;/p&gt;

&lt;p&gt;Finlay, select the new branch on GitHub then you will find a message telling you if you want to make a new pull request&lt;/p&gt;

&lt;p&gt;Click on it and you will be redirected to the second page to check if you have a conflict.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pull request simply you're saying to your colleague that you have changed the code and you want them to review and merge it with the master&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's it, not hard but effective.&lt;/p&gt;

&lt;p&gt;Now your feature is created and ready to be tested by the testers. after they approve it they will merge it with the master to go live.&lt;/p&gt;

&lt;p&gt;congrats buddy you really did a great job and deserve a holiday.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>6 Useful Methods For Javascript Objects ✨</title>
      <dc:creator>Abddelrahman Saad</dc:creator>
      <pubDate>Thu, 03 Dec 2020 23:35:59 +0000</pubDate>
      <link>https://dev.to/abdelrahman/6-useful-methods-for-javascript-objects-5aoc</link>
      <guid>https://dev.to/abdelrahman/6-useful-methods-for-javascript-objects-5aoc</guid>
      <description>&lt;p&gt;Hello guys, today we're going to explore the most used object methods with javascript.&lt;/p&gt;

&lt;p&gt;let's div deep directly.&lt;/p&gt;

&lt;h1&gt;
  
  
  1-Object.values()
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;return array of the object's values&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;assume we've got this object and we need to get the values only.&lt;br&gt;
&lt;/p&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;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Audi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2020&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;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;car&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;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;//output ['Audi', 'a4', 2020]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  2-Object.keys()
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;it's the opposite of the first function it return array of the object's Keys(names)&lt;/strong&gt;&lt;br&gt;
&lt;/p&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;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Audi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2020&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;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;car&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;keys&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;//output ['name', 'model', year]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;easy, right?&lt;/p&gt;

&lt;h1&gt;
  
  
  3-Object.assign()
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;it's Useful for merging or cloning objects&lt;/strong&gt;&lt;br&gt;
&lt;/p&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;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Audi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2020&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;details&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Coupe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2021&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;combined&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt;&lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;details&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;combined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;//output {name:'Audi', model:'a4', color:'red', type:'Coupe', year:2021}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Note Here: if both objects have the same property, it will take the value of the second object
&lt;/h3&gt;

&lt;h1&gt;
  
  
  4-Object.entries()
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;return array for each key:value pairs in object wrapped in array&lt;/strong&gt;&lt;br&gt;
&lt;/p&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;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Audi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2020&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;items&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;car&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;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;//output [ [name:'Audi'], [model:'a4'], [year:2020] ]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  5-Object.freeze()
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;it makes the object no longer able to change&lt;/strong&gt;&lt;br&gt;
&lt;/p&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;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Audi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;freeze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2021&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;car&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;//output [ [name:'Audi'], [model:'a4'], [year:2020] &lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Note Here: to check if the object is frozen or not use Object.isFrozen(car), if frozen it will return true, and false if not
&lt;/h3&gt;

&lt;h1&gt;
  
  
  6-Object.seal()
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Similar to Object.freeze() but the difference is this lets you change the property of the object as long they are writeable (Not methods) But not delete or add new&lt;/strong&gt;&lt;br&gt;
&lt;/p&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;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Audi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="c1"&gt;//this will work&lt;/span&gt;
  &lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2021&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;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// output 2021&lt;/span&gt;

  &lt;span class="c1"&gt;//this will Not work&lt;/span&gt;
  &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&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;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// output 2021&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Note Here: to check if the object is sealed or not use Object.isSealed(car), if sealed it will return true, and false if not.
&lt;/h2&gt;

&lt;p&gt;That's it for today, I hope this was useful to you.&lt;br&gt;
Thank you, and have a productive day❤️&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>8 Useful Javascript Array Methods✨</title>
      <dc:creator>Abddelrahman Saad</dc:creator>
      <pubDate>Sat, 14 Nov 2020 23:12:02 +0000</pubDate>
      <link>https://dev.to/abdelrahman/javascript-array-methods-for-beginners-411d</link>
      <guid>https://dev.to/abdelrahman/javascript-array-methods-for-beginners-411d</guid>
      <description>&lt;p&gt;Hello guys, today we're going to explore the most used array methods with javascript&lt;/p&gt;

&lt;p&gt;Such as (push, shift, filter, reduce, and more..)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I assume you know that array is a data type used for storing lists of almost any other data types such as(Objects, Strings, Numbers, etc...)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So let's begin with the first method&lt;/p&gt;

&lt;h2&gt;
  
  
  1-Push()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;push is straightforward it used to add a new element to the end of the array.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's give it a try.&lt;/p&gt;

&lt;p&gt;Start with declaring the array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;3&lt;/span&gt;  &lt;span class="p"&gt;];&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;here we got an array with numbers, now let's add another element to &lt;em&gt;the end&lt;/em&gt; of the array with push&lt;/p&gt;

&lt;p&gt;then print to the console to see what happened.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;arry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&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;arry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if you following along with me you're going to see the output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="c1"&gt;//[  1,  2,  3,  4  ]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;easy right?&lt;/p&gt;

&lt;p&gt;Now let's move to the second method.&lt;/p&gt;

&lt;h2&gt;
  
  
  2-Pop()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;pop is easy also, it removes the last element in the array.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;with the same array, we declared before, after adding the new element, ﻿let's remove it.&lt;/p&gt;

&lt;p&gt;you remember that push added the element at end of the array ha!&lt;/p&gt;

&lt;p&gt;then with pop() as we said it removes the last element which is at the end of the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;arry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pop&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;arry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// output [ 1, 2, 3 ];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3- shift()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Shift is the opposite of pop, it removes the first element in the array.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;arry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shift&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;arry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// [  2,   3,  4 ];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4 - unshift()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;it adds new element at the beginning of array.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;arry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;unshift&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&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;arry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// [  4,  1,   2,   3  ];&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;now let's move to another set of methods which so useful for work with javascript arrays.&lt;/p&gt;

&lt;h2&gt;
  
  
  5-filter()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;filter loops through the array and return another array with one or many elements match the criteria.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;what does this mean!&lt;/p&gt;

&lt;p&gt;let me tell you an example&lt;/p&gt;

&lt;p&gt;imagine you got an array of users,&lt;/p&gt;

&lt;p&gt;and function responsible to find and return users that have the same name passed to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="err"&gt;﻿&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ahmed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;khalid&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;}];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="c1"&gt;//find the users with name&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so you got variable with requested name,&lt;/p&gt;

&lt;p&gt;now we can use filter to find these user/s :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="err"&gt;﻿&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ahmed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;khalid&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;}];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;requestedUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;user&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;===&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;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;requestedUsers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="c1"&gt;// output  [ { name: 'ahmed',  age: 20 } ]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;what is going on here is we use filter to loop throughout the whole array and find any user got name equal to the name passed to the function then &lt;strong&gt;return an array&lt;/strong&gt; with element/s that match the criteria.&lt;/p&gt;

&lt;p&gt;if you got this function the next two functions the almost the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  6-find()
&lt;/h2&gt;

&lt;p&gt;The one and the only difference between this and filter() is instead of looping through the whole array and return an array with requested element/s,&lt;/p&gt;

&lt;p&gt;it loops until it finds &lt;em&gt;the first&lt;/em&gt; element matched the criteria then it stops the loop and &lt;strong&gt;returns the element only&lt;/strong&gt; &lt;br&gt;
-not inside an array.-&lt;/p&gt;
&lt;h2&gt;
  
  
  7-findIndex()
&lt;/h2&gt;

&lt;p&gt;Same as find(), loop until it found the first element matched the criteria but instead of returning the element itself returns the index of the element.&lt;/p&gt;

&lt;p&gt;I'm not laying at you as I said they almost the same right?😉&lt;/p&gt;
&lt;h2&gt;
  
  
  8-map()
&lt;/h2&gt;

&lt;p&gt;It loops through the array but here it returns a new array with the needed value only from the old one.&lt;/p&gt;

&lt;p&gt;hold one and let me explain.&lt;/p&gt;

&lt;p&gt;Again with our user's array but here I added id fields to each user for the sake of example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="err"&gt;﻿&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ahmed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;   &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;khalid&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Imagine you need to send this array to users but you don't want to expose the ids and ages of users or the users interested only in names. &lt;br&gt;
so desired output would be [ "ahmed", "khalid" ].&lt;/p&gt;

&lt;p&gt;here come the main roles of the map function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&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="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; 
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&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;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;names&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="c1"&gt;// output  [ " ahmed ",   "khalid"  ]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Got it?&lt;/p&gt;

&lt;p&gt;it returns a new array from the original one -without touch the original-, but it only returns the desired fields from the original array.&lt;br&gt;
you need names of users so got the names only in a new array&lt;/p&gt;
&lt;h2&gt;
  
  
  9-reduce()
&lt;/h2&gt;

&lt;p&gt;reduce is different from anyone, it comes with terminology such as &lt;em&gt;reducer &amp;amp; accumulator&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;-The reducer is what action or the operation will perform in order to get to one value at the end.&lt;/p&gt;

&lt;p&gt;-The accumulator is the value that we end with, in other words, it's what we depend on for the next iteration.&lt;/p&gt;

&lt;p&gt;please don't give that face and let's talk code instead.🙃&lt;/p&gt;

&lt;p&gt;imagine you have this array of books with names and the total sold items of each one and you need to get the total sold items overall.&lt;br&gt;
&lt;/p&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;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;awesome book&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;sold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;new book&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;sold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;great book&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;sold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;let me write the function and I will describe it to you&lt;br&gt;
&lt;/p&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;totalSold&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;accu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;accu&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sold&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;the accu parameter changes to the returned value of the previous iteration, but when we start the function there's no previous iteration,&lt;br&gt;
do you notice the 0, its the initial value for first execution  -it's not a must - &lt;/p&gt;

&lt;p&gt;So the returned value from the first iteration would be 8&lt;/p&gt;

&lt;p&gt;0 + 8  &lt;em&gt;The initial value + sold items for awesome book&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;In the next iteration, the accu parameter changed to the returned value from the previous iteration which is 8&lt;br&gt;
so the result of the iteration going to be 20&lt;/p&gt;

&lt;p&gt;8 + 12  &lt;em&gt;the accu parameter + sold items for new book&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;In the last iteration, the accu changed to 20 which is the returned value from the previous iteration,&lt;br&gt;
so the result of the last iteration going to be 24 &lt;/p&gt;

&lt;p&gt;20 + 4  &lt;em&gt;the accu parameter + sold items for great book&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Finally, there's no iteration so the returned value from the reduce function would be the last returned value which is 24.&lt;/p&gt;

&lt;p&gt;I hope that was good enough to wrap your head about reduce.&lt;/p&gt;

&lt;p&gt;that's was a summary for most used javascript array methods&lt;br&gt;
if you want an advanced article please let me know in the comments.&lt;/p&gt;

&lt;p&gt;Thank you, and have a productive day❤️&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>3 Unique Javascript Window APIS ✨</title>
      <dc:creator>Abddelrahman Saad</dc:creator>
      <pubDate>Wed, 11 Nov 2020 19:42:36 +0000</pubDate>
      <link>https://dev.to/abdelrahman/unique-javascript-window-apis-you-don-t-know-about-2fle</link>
      <guid>https://dev.to/abdelrahman/unique-javascript-window-apis-you-don-t-know-about-2fle</guid>
      <description>&lt;p&gt;Javascript has a powerful built-in API that makes our life easier as developers.&lt;/p&gt;

&lt;p&gt;Today we're going to cover 3 of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: These APIS are experimental so you need to check of the browser support them first before using it in production&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1-navigator.Online:
&lt;/h2&gt;

&lt;p&gt;Lets you check the user internet connection, return false if the connection is lost and true when it back&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;online&lt;/span&gt; &lt;span class="p"&gt;)&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; You're offline, check your connection. 🔴&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; Your connection is back 🟢&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2-navigator.language:
&lt;/h2&gt;

&lt;p&gt;Lets you get the language of the browser&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&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="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;language&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

 &lt;span class="c1"&gt;//output en-Us&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3-navigator.geolocation:
&lt;/h2&gt;

&lt;p&gt;Lets you get the location of the device&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;geolocation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getCurrentPosition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;displayPosition&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;displayPosition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;position&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Latitude:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;position&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;coords&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;latitude&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Longitude:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;position&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;coords&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;longitude&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

 &lt;span class="c1"&gt;//Latitude: 40.1294478&lt;/span&gt;
&lt;span class="c1"&gt;//Longitude: 41.34804699999998&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it, Have a productive day ❤️&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Unique tip for CSS ✨</title>
      <dc:creator>Abddelrahman Saad</dc:creator>
      <pubDate>Mon, 09 Nov 2020 16:45:55 +0000</pubDate>
      <link>https://dev.to/abdelrahman/unique-tip-for-css-5a15</link>
      <guid>https://dev.to/abdelrahman/unique-tip-for-css-5a15</guid>
      <description>&lt;p&gt;Hello guys, I've found a very useful tip I didn't know before and I would like to share it with you.&lt;/p&gt;

&lt;p&gt;Have you tried before to make a shadow for a transparent picture and the final outcome became something like that😒&lt;/p&gt;

&lt;p&gt;&lt;a href="https://freeimage.host/i/F3HEaj" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fiili.io%2FF3HEaj.md.png" alt="F3HEaj.md.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and you want it to be something like that🤩&lt;/p&gt;

&lt;p&gt;&lt;a href="https://freeimage.host/i/F3HXwB" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fiili.io%2FF3HXwB.md.png" alt="F3HXwB.md.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok here's the way you can achieve the awesome result✨&lt;/p&gt;

&lt;h3&gt;
  
  
  instead of
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;box-shadow: 2px 4px 6px #ff8429&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  do it like this
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;filter: drop-shadow(2px 4px 6px #ff8429)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's it, have a productive day❤️&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>design</category>
    </item>
    <item>
      <title>Introduction to recursion (Part 2 Practical)</title>
      <dc:creator>Abddelrahman Saad</dc:creator>
      <pubDate>Sun, 08 Nov 2020 23:11:00 +0000</pubDate>
      <link>https://dev.to/abdelrahman/introduction-to-recursion-practical-2odm</link>
      <guid>https://dev.to/abdelrahman/introduction-to-recursion-practical-2odm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Important Note&lt;/strong&gt;&lt;br&gt;
Please note that there is a first part that must be read before reading this part&lt;br&gt;
&lt;a href="https://dev.to/abd_elrahmanmo/introduction-to-recursion-1ack"&gt;Read from here&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now let's get our hands dirty and make a simple function to demonstrate our idea.&lt;br&gt;
imagine you need to count down from a number till 0 what would you do!!&lt;br&gt;
Yes, a loop gets the number and subtract 1 at every iteration.&lt;/p&gt;

&lt;p&gt;so it would be something like that&lt;/p&gt;

&lt;p&gt;First, we make a function call count down take the number and make a loop inside it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;countDown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;I&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;--&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;i&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Done&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you invoke this function with a number let's say 4 the output  would be&lt;br&gt;
4&lt;br&gt;
3&lt;br&gt;
2&lt;br&gt;
1&lt;br&gt;
0&lt;br&gt;
Done&lt;/p&gt;

&lt;p&gt;NOW let's do it recursively&lt;/p&gt;

&lt;p&gt;Here where things get exciting🤩&lt;/p&gt;

&lt;p&gt;I'll write the function but don't worry I'll walk through it step by step&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;countDown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Done&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&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;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;
  &lt;span class="nx"&gt;countDown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;countDown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please don't freak out, and have another look🧐&lt;/p&gt;

&lt;p&gt;The first thing it will check if &lt;strong&gt;num&lt;/strong&gt; is less than or equal to 0 and it's not -it's 3 - then it will skip this part as we also.&lt;/p&gt;

&lt;p&gt;Then it will print the number in the console - 3 -&lt;br&gt;
then subtract 1 from the number so it's going to be 2 instead of 3,&lt;br&gt;
until now this is normal to you off course.&lt;/p&gt;

&lt;p&gt;In the next part, it will execute itself again but this time with the subtracted number which is now &lt;strong&gt;2&lt;/strong&gt; so the countDown function would invoke again with different input.&lt;/p&gt;

&lt;p&gt;The first role you remember it arent you?🤔&lt;/p&gt;

&lt;h2&gt;
  
  
  Different input
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The first role to make the function recursion it has to work every time with different input&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You passed the first part I'm proud of you 🥳👏&lt;/p&gt;

&lt;p&gt;Now let get back to our function.&lt;/p&gt;

&lt;p&gt;The function will check again if num is less than or equal to 0 and it's not - it's 2 this time - then it will skip this part again&lt;br&gt;
then it will print the number - 2 - &lt;br&gt;
then subtract 1 from the number which is becoming &lt;strong&gt;1&lt;/strong&gt; now after subtraction &lt;/p&gt;

&lt;p&gt;and again it will execute itself with the new input &lt;strong&gt;1&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;it will do the check again but it will skip the check because it's not less than or equal to 0 - it's 1 - &lt;br&gt;
then print the number and subtract 1 from the number and execute itself again but NOW the number became &lt;strong&gt;0&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now the if statement will work because the number is equal to 0&lt;/p&gt;

&lt;p&gt;This is the second and final part of the recursion functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The base case
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;the function must have a time where it stops and returns a value, or we're going to have an infinite loop.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;it will return nothing here but we do it because this part is the most important one and without it as you know it won't stop and your program going to crash undoubtedly &lt;/p&gt;

&lt;p&gt;HOLA now you've understood the recursion functions and I didn't cheat you it's simple, right? 🥳&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let's be honest this not what recursion meant to do but here for the sake of simplicity and learning but in real-life scenarios, you would use recursion functions as we said in a big number of items&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you interested I can do an advanced one please let me know in the comments and I'll do it as soon as possible&lt;/p&gt;

&lt;p&gt;Thank You, and have a productive day ❤️&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Introduction to recursion (Part 1 Theory)</title>
      <dc:creator>Abddelrahman Saad</dc:creator>
      <pubDate>Sat, 07 Nov 2020 19:12:12 +0000</pubDate>
      <link>https://dev.to/abdelrahman/introduction-to-recursion-1ack</link>
      <guid>https://dev.to/abdelrahman/introduction-to-recursion-1ack</guid>
      <description>&lt;p&gt;Have you ever heard the term recursion function!?&lt;/p&gt;

&lt;p&gt;if you're a developer - and you are of course - the answer would be definitely YES!&lt;/p&gt;

&lt;p&gt;maybe this term makes you a little bit confused or maybe scared (as I'm at the first sight ) but please calm down it's really easy and very helpful.&lt;/p&gt;

&lt;p&gt;We're going to divide this talk into two parts&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Theory&lt;/strong&gt; and &lt;strong&gt;Practical&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Theory.
&lt;/h1&gt;

&lt;p&gt;In theory, we need to answer 3 questions What, Why, and How.&lt;/p&gt;

&lt;h3&gt;
  
  
  WHAT?
&lt;/h3&gt;

&lt;p&gt;ok, let's make it as simple as it indeed is.&lt;/p&gt;

&lt;p&gt;Recursion is a "function calls itself".&lt;br&gt;
Simply from the body of the function, we use the same function again over and over until reaches a certain result.&lt;/p&gt;

&lt;p&gt;Yes, I've heard your question 😃&lt;br&gt;
why would I make a function to call itself again and what the benefits of doing so?&lt;/p&gt;

&lt;p&gt;Here we go to the next question&lt;/p&gt;

&lt;h3&gt;
  
  
  WHY?
&lt;/h3&gt;

&lt;p&gt;recursion as you already guessed (maybe not) is similar to loops.&lt;/p&gt;

&lt;p&gt;But when you work with a large number of data (Objects, Numbers, etc.)&lt;br&gt;
loops became a cumbersome process to our program and maybe break it, especially when you make two loops in the same process or loop inside a loop this consumes a lot of resources and slows down the process.&lt;/p&gt;

&lt;p&gt;But we as developers always trying to make our code clean, fast, and as efficient as possible, Right?&lt;/p&gt;

&lt;p&gt;In this situation recursion becomes handy.&lt;/p&gt;

&lt;p&gt;we use it when we got a big number of data we need to loop inside it but you care about the time and readability and efficiency of your code, ok?&lt;/p&gt;

&lt;p&gt;let's jump to the last question of &lt;strong&gt;theory&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  HOW?
&lt;/h3&gt;

&lt;p&gt;here's how it works, there are two parts recursion function must have to be a recursion&lt;/p&gt;

&lt;p&gt;1-Different input:&lt;br&gt;
we agreed that it's a "function calls itself" so it doesn't make sense to give the function the same input and expect to do a different thing so every time the function executed must have different input.&lt;/p&gt;

&lt;p&gt;2-Base case:&lt;br&gt;
because recursion function kinda loop,&lt;br&gt;
and every loop must have a time where it stops and returns a value, or we're going to have an infinite loop.&lt;br&gt;
the time we stop our recursion function is the base case of the function.&lt;br&gt;
so when we say the base case of the recursion function it means the phase that stops and returns its result.&lt;/p&gt;

&lt;p&gt;That's it for theory, I hope it was simple, and follow me for more ❤️&lt;/p&gt;

&lt;h3&gt;
  
  
  The practical part here
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://dev.to/abd_elrahmanmo/introduction-to-recursion-practical-2odm"&gt;https://dev.to/abd_elrahmanmo/introduction-to-recursion-practical-2odm&lt;/a&gt;]&lt;/p&gt;

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