<?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: Shihaan W S</title>
    <description>The latest articles on DEV Community by Shihaan W S (@shihaanws).</description>
    <link>https://dev.to/shihaanws</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%2F450694%2Fefaa5401-72b0-4ecf-99d9-589224ed1e33.jpg</url>
      <title>DEV Community: Shihaan W S</title>
      <link>https://dev.to/shihaanws</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shihaanws"/>
    <language>en</language>
    <item>
      <title>What exactly do props do in React?</title>
      <dc:creator>Shihaan W S</dc:creator>
      <pubDate>Thu, 31 Dec 2020 14:49:26 +0000</pubDate>
      <link>https://dev.to/shihaanws/what-exactly-does-props-do-to-react-129f</link>
      <guid>https://dev.to/shihaanws/what-exactly-does-props-do-to-react-129f</guid>
      <description>&lt;h1&gt;
  
  
  Props - a beginners guide.
&lt;/h1&gt;

&lt;p&gt;Before getting to know what props are, lets have a basic understanding of what React elements and components are. Also, in this article I’ll be explaining props in the simplest way possible, for all beginners out there who can't get a good grasp around this concept.&lt;br&gt;
So lets get started 💫&lt;/p&gt;
&lt;h1&gt;
  
  
  React components vs. Elements
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XiN9_S1R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1t4fupcyalgy8rtpprgw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XiN9_S1R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1t4fupcyalgy8rtpprgw.png" alt="Alt Text" width="651" height="257"&gt;&lt;/a&gt;&lt;br&gt;
As we all know, React uses JSX (JavaScript XML) instead of HTML. JSX allows you to write HTML elements in javascript files, and then translate those HTML tags to React elements.&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;// This is a React element, not a component&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Heading&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how a plain &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag looks inside jsx.&lt;br&gt;
So basically, a React element is the smallest building block, and more elements put together form a component&lt;/p&gt;

&lt;p&gt;Okay, lets move on to components. A React component is a javascript function which also returns the markup that we want to see (like the elements), but through classical function syntax.&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;Component&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the component is created as a javascript function, so it is referred to as functional component.&lt;br&gt;
This component is rendered in the same way as an element, by using the render() method of the ReactDOM. But, instead of calling the function name like we do in javascript, we call the React component.&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;//In React&lt;/span&gt;
&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;//In Javascript&lt;/span&gt;
&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&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;



&lt;p&gt;So, a React element uses regular HTML tags, while in a React component, the function name gives the name of the tag.&lt;/p&gt;

&lt;h1&gt;
  
  
  Props
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Props are the arguments you pass into a React component that then render a React element.It can be a string, object, array or a function used to pass dynamic data between components. React has a uni-directional data flow meaning props get passed from parent to child. Props actually gets passed into React components.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I guess that was not really helpful, so let me reword a little bit to simple language 🔍&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Props are like parameters of a function. We use these to make our component dynamic like we use parameters to make our function dynamic.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Was that better? Now with this definition in mind, let me show you a quick example.&lt;br&gt;
Lets look at a component to display a Welcome message to a friend in your channel.&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;WelcomeFriend&lt;/span&gt; &lt;span class="o"&gt;=&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;my&lt;/span&gt; &lt;span class="nx"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Kiran&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/span&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now If I want to welcome to any person not just Kiran, I can refactor my component to take in a prop i.e the name of person and rename the component to any common name because now I can use this component to welcome anyone in my channel.&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;Welcome&lt;/span&gt; &lt;span class="o"&gt;=&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;my&lt;/span&gt; &lt;span class="nx"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;,&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/span&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And Now I can Welcome many of my friends like 👇🏻&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;App&lt;/span&gt; &lt;span class="o"&gt;=&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sumesh&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Keshav&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Roger&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope you found this guide helpful! ✌🏻&lt;br&gt;
I welcome feedback, discussion, and suggestions for concepts you'd like to see me tackle. If you have any question regarding this or anything I should add, correct or remove, feel free to comment, email or DM me 📥.&lt;br&gt;
Thanks ✨!&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding the 'three dot' operator better.</title>
      <dc:creator>Shihaan W S</dc:creator>
      <pubDate>Sat, 19 Dec 2020 16:17:41 +0000</pubDate>
      <link>https://dev.to/shihaanws/understanding-the-three-dot-operator-better-1ib7</link>
      <guid>https://dev.to/shihaanws/understanding-the-three-dot-operator-better-1ib7</guid>
      <description>&lt;h1&gt;
  
  
  A simple yet powerful operator.
&lt;/h1&gt;

&lt;p&gt;When you look at most of the common web-related programming languages they all have the basic operators, which almost every developer out there knows how to use them. But there are some operators that aren't much common and not every language has them or if they do, they might not share the same syntax. But for newcomers into a language, trying to read other's code and not having the tools required to understand concepts between technologies, it might be a problem. So in this article, I'm going to talk about one most Javascript's underrated and infamous   &lt;strong&gt;"spread"&lt;/strong&gt; operator a.k.a the three dot (...) operator. Come! Let's start exploring!&lt;/p&gt;

&lt;h1&gt;
  
  
  Spread Operator
&lt;/h1&gt;

&lt;p&gt;Javascript has seen massive improvements in its syntax and functionality over the the past few years with the addition of a bunch of new features. Spread is the one among the most useful ones and also the simplest way to go  if you want to update a piece of data in an object while creating a new object. Its a very powerful piece of syntax which has a lot of applications in programming.&lt;br&gt;
For now, its hard to keep a track of them all. So lets dig into some of the most common use cases of the spread operator.&lt;/p&gt;
&lt;h1&gt;
  
  
  Making a copy of an array
&lt;/h1&gt;

&lt;p&gt;Lets understand this with a small example.&lt;br&gt;
Who are your favourite cricketers?&lt;br&gt;
Mine? Its Dhoni and Raina, obviously.&lt;br&gt;
Okay. Lets take this in an 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;favourites&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;Dhoni&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;Raina&lt;/span&gt;&lt;span class="dl"&gt;"&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;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;favourites&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;copy&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// ["Dhoni","Raina" ]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;If you look at in a different way, the spread operator is selecting each individual element inside the favourite array and placing each of those elements in a new array structure, which is something like spreading. Now you might think what happens if there's no spread operator.&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;favourites&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;Dhoni&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;Raina&lt;/span&gt;&lt;span class="dl"&gt;"&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;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;favourites&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;copy&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//  [["Dhoni","Raina" ]]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This ones different because we are getting a multidimensional array (an array inside an array).&lt;/p&gt;

&lt;h1&gt;
  
  
  Expanding an array
&lt;/h1&gt;

&lt;p&gt;Building on the previous example, lets say I want a new player to be in my favourites list. The Spread operator provides a simple and effective way to do this.&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;favourites&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;Dhoni&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;Raina&lt;/span&gt;&lt;span class="dl"&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;favourites&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Smith&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//  Dhoni Raina Smith&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;As simple as that. Here we don't get  an array since we aren't asking for an array structure unlike we did in the previous case. So this way you could update your data without actually overwriting to your existing data.&lt;/p&gt;

&lt;h1&gt;
  
  
  String Spreading
&lt;/h1&gt;

&lt;p&gt;The spread operator also works with string spreading. One practical example is extracting characters from a string.&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;player&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sachin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;//Spread Operator extracts the characters from the String and assigns to an array&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;characters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;player&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;characters&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;//Output -&amp;gt; Array (6) ["S", "a", "c", "h","i","n"]&lt;/span&gt;

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

&lt;/div&gt;



&lt;h1&gt;
  
  
  Merging Objects
&lt;/h1&gt;

&lt;p&gt;Merging of objects is almost similar to merging arrays except for some key-value conditions.&lt;br&gt;
If you have unique key the key-value get added to the new object. If the key is same, the value gets replaced with the new value.&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;match1&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="s2"&gt;Sachin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="na"&gt;score&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;56&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;match2&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="s2"&gt;Sachin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="na"&gt;score&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;balls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;32&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;match&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{...&lt;/span&gt;&lt;span class="nx"&gt;match1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;match2&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;match&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="c1"&gt;// Output -&amp;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="s2"&gt;Sachin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;score&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;balls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;
             &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So that's all for this article. Apart from these, spread syntax has a lot of other applications. Enjoy trying it out  and accept these new tools the language is giving you. Hope you loved the article, do let me know your feedback in the comment section below.&lt;/p&gt;

&lt;p&gt;For a whole lot about spread syntax please refer to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax"&gt;MDN Web Docs.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See you in the next one 👋&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Triggering your first API request with Postman.</title>
      <dc:creator>Shihaan W S</dc:creator>
      <pubDate>Sat, 28 Nov 2020 08:58:48 +0000</pubDate>
      <link>https://dev.to/shihaanws/triggering-your-first-api-request-with-postman-db0</link>
      <guid>https://dev.to/shihaanws/triggering-your-first-api-request-with-postman-db0</guid>
      <description>&lt;p&gt;&lt;strong&gt;A beginner friendly tutorial to get started with Postman.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hello there 👋&lt;br&gt;
Almost everyone who works into web development, front-end or back-end, has in some part of their development heard of  "Postman" or some other API testing service to test their app they are building. But, do we all know how powerful Postman is?&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyeea9z58z2cqvsg7u99s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyeea9z58z2cqvsg7u99s.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So today I would like you to join me on a short adventure of writing a simple API test with Postman, let's go!&lt;/p&gt;

&lt;p&gt;This Tutorial assumes you to have some familiarity with API. So I am not going to explain what an API is, or why you should care, or any of that. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"A Beginner's Guide To APIs" : &lt;a href="https://dev.to/hpsetti/a-begineer-s-guide-to-apis-4b4d"&gt;Check here!&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Basically, You can send requests in Postman to connect to APIs you are working with. Your requests can &lt;strong&gt;&lt;em&gt;retrieve, add, delete, and update data.&lt;/em&gt;&lt;/strong&gt; Whether you are building or testing your own API, or integrating with a third-party API, you can try out your requests in Postman.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsigojozgvjxl9zrd1460.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsigojozgvjxl9zrd1460.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For example, if you're building a client application (e.g. a mobile or web app) for a shop, you might send one request to &lt;strong&gt;retrieve&lt;/strong&gt; the list of available products, another request to &lt;strong&gt;create&lt;/strong&gt; a new order (including the selected product details), and a different request to log a customer in to their account.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When you send a request, Postman will display the response received from the API server in a way that lets you examine, visualize and troubleshoot.&lt;/p&gt;

&lt;p&gt;Okay! Let’s start talking to the API, yeah? First let’s download Postman.&lt;br&gt;
&lt;a href="https://www.postman.com/downloads/" rel="noopener noreferrer"&gt;https://www.postman.com/downloads/&lt;/a&gt;&lt;br&gt;
Postman is free software that lets you test APIs. You can test other people’s public APIs, like we will do today.&lt;/p&gt;

&lt;p&gt;We are going to use &lt;a class="mentioned-user" href="https://dev.to/kennethreitz"&gt;@kennethreitz&lt;/a&gt;'s web-exposed API for our first test, &lt;a href="https://github.com/postmanlabs/httpbin" rel="noopener noreferrer"&gt;httpbin&lt;/a&gt; to try out Postman.&lt;/p&gt;

&lt;p&gt;Once you’ve downloaded and installed Postman, if it gives you any tutorial popups, just skip them.There’s a bunch of buttons and words we don’t need to care about right now.&lt;/p&gt;

&lt;h3&gt;
  
  
  First GET Request
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Type &lt;a href="http://httpbin.org/get" rel="noopener noreferrer"&gt;http://httpbin.org/get&lt;/a&gt; in the enter URL request field.&lt;/li&gt;
&lt;li&gt;To try out the  endpoint, leave the GET method selected and click Send.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fok1jk5vv04lxu38twrfz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fok1jk5vv04lxu38twrfz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You will find the status code &lt;strong&gt;200 OK&lt;/strong&gt; which means that EndPoint is correct and it has returned the desired results.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu4o0o0wewnavgn4ztc26.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  First POST Request
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Type &lt;a href="http://httpbin.org/post" rel="noopener noreferrer"&gt;http://httpbin.org/post&lt;/a&gt; in the enter URL request field.&lt;/li&gt;
&lt;li&gt;Leave the POST method selected from the dropdown.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As soon as you select the POST request type in Postman you      will see that the option Body is enabled which has different options to send the data inside the body.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Form-data&lt;/li&gt;
&lt;li&gt;X-www-form-urlencoded&lt;/li&gt;
&lt;li&gt;Raw&lt;/li&gt;
&lt;li&gt;Binary
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqvzqme34nm28ufa8s06e.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;For post you will need form data to be posted .&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;For now, lets stick on to &lt;strong&gt;&lt;em&gt;form-data&lt;/em&gt;&lt;/strong&gt;. Type your required key-value pair and click Send.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F63rklm2kb3ham5fso8d6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F63rklm2kb3ham5fso8d6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Again you will find the status code &lt;strong&gt;200 OK&lt;/strong&gt;, the time taken to process your post request and your new JSON data with added key-value data.&lt;/li&gt;
&lt;li&gt;So this way you could visualize,test and debug your API endpoints.


Wasn't that amazing?
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faabtou1pn0rraqdnwnui.gif" alt="Alt Text"&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That was all for this article. Today you've learned how to  send a GET/POST request to a public API and experimenting with your data.&lt;br&gt;
If you want to learn more about Postman and its features refer to the following links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/channel/UCocudCGVb3MmhWQ1aoIgUQw" rel="noopener noreferrer"&gt;Postman Official YouTube Channel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learning.postman.com/docs/getting-started/introduction/" rel="noopener noreferrer"&gt;Postman Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enjoy building cool APIs ✨&lt;/p&gt;

</description>
      <category>testing</category>
      <category>api</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
