<?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>Forem: Yash</title>
    <description>The latest articles on Forem by Yash (@yashguptaz).</description>
    <link>https://forem.com/yashguptaz</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%2F251314%2Fb2d8148c-ce8e-4e42-8b87-e8a825b995f5.png</url>
      <title>Forem: Yash</title>
      <link>https://forem.com/yashguptaz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/yashguptaz"/>
    <language>en</language>
    <item>
      <title>Add open with Neovide Option in Windows 10</title>
      <dc:creator>Yash</dc:creator>
      <pubDate>Sun, 09 May 2021 06:01:04 +0000</pubDate>
      <link>https://forem.com/yashguptaz/add-open-with-neovide-option-in-windows-10-1cej</link>
      <guid>https://forem.com/yashguptaz/add-open-with-neovide-option-in-windows-10-1cej</guid>
      <description>&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open Notepad or your preferred text editor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy the script below&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with Neovim]
@="Edit with Neovim"
"Icon"="C:\\Program Files\\neovide\\neovide.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with Neovim\command]
@="\"C:\\Program Files\\neovide\\neovide.exe\" \"%1\""

; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\neovide]
@="Open Folder as Neovim Project"
"Icon"="\"C:\\Program Files\\neovide\\neovide.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\neovide\command]
@="\"C:\\Program Files\\neovide\\neovide.exe\" \"%1\""

; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\Background\shell\neovide]
@="Open Folder as Neovim Project"
"Icon"="\"C:\\Program Files\\neovide\\neovide.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\neovide\command]
@="\"C:\\Program Files\\neovide\\neovide.exe\" \"%V\""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Paste it in the text editor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the file as &lt;code&gt;neovideOpenFolder.reg&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now you can have a nice open with Neovim option.&lt;/p&gt;

&lt;p&gt;If it doesn't work check the paths of Neovide in the script.&lt;br&gt;
You can also change Neovim to Neovide if you like.&lt;/p&gt;

</description>
      <category>neovide</category>
      <category>neovim</category>
      <category>windows</category>
    </item>
    <item>
      <title>Disclosure of JavaScript Closures.</title>
      <dc:creator>Yash</dc:creator>
      <pubDate>Sun, 24 May 2020 13:30:06 +0000</pubDate>
      <link>https://forem.com/yashguptaz/disclosure-of-javascript-closures-1ac8</link>
      <guid>https://forem.com/yashguptaz/disclosure-of-javascript-closures-1ac8</guid>
      <description>&lt;p&gt;JavaScript closures are tough to wrap your head around the first time you encounter them. Some developers might come off forming a wrong mental model about closures as it is very easy to get closures in the wrong way. &lt;/p&gt;

&lt;p&gt;Perhaps reading the code that uses closure in a linear fashion can be an easily misleading way to form a wrong mental model about it. In this post I am going to disclose what closures actually are. &lt;/p&gt;

&lt;p&gt;Let's start by understanding how the JavaScript engine parses our code.&lt;/p&gt;

&lt;h2&gt;
  
  
  How JavaScript Engine Works
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;It goes by the code line by line.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Any &lt;em&gt;function declaration and variables&lt;/em&gt; it finds is put in the &lt;strong&gt;global memory&lt;/strong&gt;.&lt;br&gt;
(Putting these functions and variable in the global memory is called &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Hoisting"&gt;hoisting&lt;/a&gt;.)&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="c1"&gt;// Values like below are put in the global memory.&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;someVariable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;

   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;myFirstFunc&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="s1"&gt;This is my awesome function&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mySecondFunc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;mySecondFunc&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="s1"&gt;This is my awesome function&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;ol&gt;
&lt;li&gt;&lt;p&gt;At this point the JavaScript code is compiled, and the engine will &lt;em&gt;again go line by line&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the engine hits a function it &lt;strong&gt;checks its global memory for the function&lt;/strong&gt; and creates a temporary environment for that function which is known as its &lt;strong&gt;execution context&lt;/strong&gt;.&lt;br&gt;
The fact that the function is pulled out from the &lt;em&gt;global memory&lt;/em&gt; is worth emphasizing which you'll learn soon why.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The execution context has 2 parts - a memory and a place to execute the statements inside the function. This execution context is unique to the function.&lt;br&gt;
   The function is also added at the top of &lt;strong&gt;call stack&lt;/strong&gt;, the &lt;code&gt;global()&lt;/code&gt; always rests at the bottom of this call stack. The call stack basically tells the engine what to work on, so, the function on the top of JavaScript is what the engine will work on.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;All the arguments passed in the function are evaluated (if you pass in a variable &lt;code&gt;a&lt;/code&gt; as an argument which was assigned a value of &lt;code&gt;1&lt;/code&gt;, then &lt;code&gt;a&lt;/code&gt; is changed to &lt;code&gt;1&lt;/code&gt;), &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These evaluated arguments are added to the &lt;em&gt;memory part&lt;/em&gt; of the execution context of the function. In the memory these arguments are saved by the labels given according to the parameters of the function.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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;myElegantFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myParameterOne&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;myParameterTwo&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;myParameterOne&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;myParameterTwo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="nx"&gt;myVariableOne&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
   &lt;span class="nx"&gt;myVariableTwo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

   &lt;span class="nx"&gt;myElegantFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myVariableOne&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;myVariableTwo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

   &lt;span class="cm"&gt;/** myElegantFunction(myVariableOne, myVariableTwo)
    is changed to 
    myElegantFunction('hello', 'world')

    Let's see the memory part of the execution context of myElegantFunction,
    ----------
    myParameterOne: 'Hello'
    myParameterTwo: 'World'
    ----------
    As you can see how these arguments are saved according to the name of the parameter which we            referenced in the function declaration.
   **/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Now the statements inside of the function are executed one by one, &lt;em&gt;if it contains any variable&lt;/em&gt; it is first looked in the memory part of the &lt;em&gt;execution context&lt;/em&gt; of that function if the variable is not found then the engine tried to search for it in the global scope.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The function is removed off the &lt;em&gt;call stack&lt;/em&gt; and the &lt;code&gt;global()&lt;/code&gt; proceeds to run the JavaScript code.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To give more clarity I have made a small video animation visually explaining this process exclusively for this post.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/NPUrBP-L7qo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;By now you must have understood how the &lt;em&gt;call stack&lt;/em&gt;, &lt;em&gt;execution context&lt;/em&gt;, and &lt;em&gt;memory&lt;/em&gt; work all together to achieve the task of running your code. Keeping the above procedures in mind, this is the perfect time to introduce you to closures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting close to closures
&lt;/h2&gt;

&lt;p&gt;Let's consider a 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;function&lt;/span&gt; &lt;span class="nx"&gt;counterFunction&lt;/span&gt;&lt;span class="p"&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;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&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;increaseCounter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;counter&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;counter&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="nx"&gt;increaseCounter&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;The function &lt;code&gt;counter&lt;/code&gt; is a higher-order function as it returns another function namely &lt;code&gt;increaseCounter&lt;/code&gt;.&lt;br&gt;
Let's declare assign this function to a variable.&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;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;counterFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When JavaScript is executing the above line, it puts the function &lt;code&gt;increaseCounter&lt;/code&gt; in its &lt;code&gt;global memory&lt;/code&gt;. So what goes in the global memory with the label count is -&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;count&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;increaseCounter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;counter&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;counter&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// NOTE: Use of ':' (colon) is representational.   &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's  where things start getting interesting when we call &lt;code&gt;count&lt;/code&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="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Output is 1&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Output is 2&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Output is 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;JavaScript is in fact, getting the function from the global memory,&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;function&lt;/span&gt; &lt;span class="nx"&gt;increaseCounter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;counter&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;counter&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;Here's another animated video for the execution of the above code.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/SFlwGKpzdgg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;As the &lt;em&gt;execution context&lt;/em&gt; starts executing the statement, it encounters the variable &lt;code&gt;counter&lt;/code&gt;, the first place it checks is the memory of the &lt;em&gt;execution context&lt;/em&gt; itself and the next thing it &lt;strong&gt;should&lt;/strong&gt; check is the &lt;em&gt;global memory&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Anyone familiar with the working of the JavaScript engine should think it is impossible to get variable &lt;code&gt;counter&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;This is where &lt;em&gt;closures&lt;/em&gt; come into the play. Let's go back to where we stored &lt;code&gt;counterFunction()&lt;/code&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;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;counterFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the &lt;code&gt;increaseCounter&lt;/code&gt; is stored in the &lt;code&gt;count&lt;/code&gt; variable. &lt;strong&gt;The count variable &lt;em&gt;literally carries&lt;/em&gt; with it the variables from the function &lt;code&gt;counterFunction&lt;/code&gt;,&lt;/strong&gt; which is the function &lt;code&gt;increaseCounter&lt;/code&gt; was *return*ed from.&lt;/p&gt;

&lt;p&gt;In this state it is said that - &lt;code&gt;increaseCounter&lt;/code&gt; has a closure over &lt;code&gt;counterFunction&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The value of &lt;code&gt;counter&lt;/code&gt; is coming from the &lt;code&gt;closure&lt;/code&gt; which &lt;code&gt;increaseCounter&lt;/code&gt; carried.  Every time we call &lt;code&gt;counter++&lt;/code&gt; we don't touch the counter in the &lt;code&gt;counterFunction&lt;/code&gt; we update the &lt;code&gt;counter&lt;/code&gt; variable in the &lt;em&gt;closure&lt;/em&gt; of &lt;code&gt;increaseCounter&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;To demonstrate the fact that &lt;code&gt;counter&lt;/code&gt; being updated is not the part of &lt;code&gt;counterFunction()&lt;/code&gt; here's a neat trick.&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;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;counterFunction&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;countTwo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;counterFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Output is 1&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Output is 2&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Output is 3&lt;/span&gt;

&lt;span class="nx"&gt;countTwo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Output is 1&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Output is 4&lt;/span&gt;
&lt;span class="nx"&gt;countTwo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Output is 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;counter&lt;/code&gt; was being updated from the &lt;code&gt;counterFunction()&lt;/code&gt; instead of the closures of the function &lt;code&gt;count&lt;/code&gt; and &lt;code&gt;countTwo&lt;/code&gt; then the output of &lt;code&gt;countTwo()&lt;/code&gt; must have added on to the value updated previously by the &lt;code&gt;count()&lt;/code&gt; function. But it does not happens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I mentioned earlier how easy is it to develop a wrong mental model about closures, it is because we tend to read code linearly and tend to confuse lexical scoping to closures, they are similar but not the same.&lt;/p&gt;

&lt;p&gt;Closures are a part of the scope of a function. You can be more clear about closures if you use the JavaScript debugger in your browser's developer tool to inspect where the variables are stored.&lt;/p&gt;

&lt;p&gt;Chrome &lt;em&gt;literally&lt;/em&gt; shows the closure to be a part of that function's &lt;em&gt;scope&lt;/em&gt; which they are. Closures are not a link between two functions.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>closures</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>#discuss Do you read JavaScript Specification? Why should someone read JavaScript Specs?</title>
      <dc:creator>Yash</dc:creator>
      <pubDate>Thu, 21 May 2020 15:34:38 +0000</pubDate>
      <link>https://forem.com/yashguptaz/discuss-do-you-read-javascript-specification-why-should-someone-read-javascript-specs-4bjh</link>
      <guid>https://forem.com/yashguptaz/discuss-do-you-read-javascript-specification-why-should-someone-read-javascript-specs-4bjh</guid>
      <description>&lt;p&gt;I was talking to someone and they said that you need not read the JavaScript specs until you're implementing a parser or something.&lt;/p&gt;

&lt;p&gt;I want to know the opinions of other devs on the topic.&lt;/p&gt;

&lt;p&gt;Here's a link to the &lt;a href="https://tc39.es/ecma262/"&gt;JavaScript specifications&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>5 Tools Every Open Source Software Must Use.</title>
      <dc:creator>Yash</dc:creator>
      <pubDate>Thu, 14 May 2020 12:54:59 +0000</pubDate>
      <link>https://forem.com/yashguptaz/5-tools-every-open-source-software-must-use-33d9</link>
      <guid>https://forem.com/yashguptaz/5-tools-every-open-source-software-must-use-33d9</guid>
      <description>&lt;p&gt;So you made an open source software but it has no systematic way of showing fancy test fails when someone makes a pull request or other amazing things some good open source software are able to accomplish. In this writeup I am going to cover a few tools to make your open source software awesome!&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Testing
&lt;/h1&gt;

&lt;p&gt;Popular Tool(s) - &lt;a href="https://mochajs.org/"&gt;Mocha&lt;/a&gt;, &lt;a href="https://jestjs.io/"&gt;Jest&lt;/a&gt;, &lt;a href="https://www.cypress.io/"&gt;Cypress&lt;/a&gt; etc.&lt;/p&gt;

&lt;p&gt;Testing is really important; you don't want to make changes to your code and regret your app failing at production and that too on Friday. &lt;/p&gt;

&lt;p&gt;If you're making a library or framework or any other tool then the importance of testing is a lot more than for other apps.&lt;/p&gt;

&lt;p&gt;Basically, in a test you define what you expect a function to do, if the function misbehaves you immediately tell by seeing the test fail.&lt;/p&gt;

&lt;p&gt;Check &lt;a href="https://youtu.be/Ty74jsFHhUU"&gt;this awesome talk&lt;/a&gt; by Tomasz to learn more about tests.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Linting
&lt;/h1&gt;

&lt;p&gt;Popular Tool(s) - &lt;a href="https://eslint.org/"&gt;ESlint&lt;/a&gt; etc.&lt;/p&gt;

&lt;p&gt;ESLint checks the readability of the code and even formats it to make it more readable.&lt;/p&gt;

&lt;p&gt;For example - someone might miss an indent randomly somewhere and if it gets to GitHub or any other place where you host your code then the indent results in loss of readability of code.&lt;/p&gt;

&lt;h1&gt;
  
  
  3. Code Coverage
&lt;/h1&gt;

&lt;p&gt;Popular Tool(s) - &lt;a href="https://codecov.io/"&gt;Codecov&lt;/a&gt;, &lt;a href="https://istanbul.js.org/"&gt;Istanbul&lt;/a&gt; etc.&lt;/p&gt;

&lt;p&gt;If you have been in the dev community for a while you must have heard people say things like - "We have achieved 100% Test Coverage."&lt;/p&gt;

&lt;p&gt;These tools check how much of your code is being tested. So if someone decides to delete a few tests because the tests are failing for their changes you immediately known as code coverage has suffered.&lt;/p&gt;

&lt;p&gt;If used popular they will also warn about not meeting a targeted coverage for the software.&lt;/p&gt;

&lt;p&gt;It is recommended to target for 100% test coverage.&lt;/p&gt;

&lt;h1&gt;
  
  
  4. Compilation and Postprocessing
&lt;/h1&gt;

&lt;p&gt;Popular Tool(s) - &lt;a href="https://babeljs.io/"&gt;Babel&lt;/a&gt;, &lt;a href="https://webpack.js.org/"&gt;Webpack&lt;/a&gt;, &lt;a href="http://lisperator.net/uglifyjs/"&gt;Uglify&lt;/a&gt;, etc.&lt;/p&gt;

&lt;p&gt;You probably don't want your code to break on old machines and browsers. That's where tools like babel come in to play, Babel will compile your code in to old versions of JavaScript, for example, you wrote an arrow function, but old browsers do not support arrow functions. Babel will convert that arrow function to a regular function.&lt;/p&gt;

&lt;p&gt;Uglify.js minifies your code by removing the extra spaces, comments and even shortening the variable names.&lt;/p&gt;

&lt;p&gt;Extremely size efficient libraries like Preact rely heavily on uglifier and use very custom settings for the best optimization.&lt;/p&gt;

&lt;h1&gt;
  
  
  5. CI/CD
&lt;/h1&gt;

&lt;p&gt;Popular Tool(s) - &lt;a href="https://travis-ci.org/"&gt;TravisCI&lt;/a&gt;, &lt;a href="https://github.com/features/actions"&gt;GitHub Actions&lt;/a&gt; etc.&lt;/p&gt;

&lt;p&gt;Ever saw fancy test failing in a GitHub PR, these are features that a CI/CD tool will provide.&lt;br&gt;
Awesome Tools like Travis allow you to Test and Deploy your application. So, whenever you push your code to the repo or someone create pull request, Travis CI will run the code and check if the tests are passing or not.&lt;/p&gt;

&lt;p&gt;If the tests of a PR are failing then it will give an error right there in GitHub that the tests are failing.&lt;/p&gt;

&lt;p&gt;On an ending note, there are many other popular must have in libraries but the 5 tools I have listed are the ones that I personally really like to have.&lt;/p&gt;

&lt;p&gt;Thanks for reading this post. &lt;/p&gt;

&lt;h3&gt;
  
  
  About Me
&lt;/h3&gt;

&lt;p&gt;I am a 17-year-old passionate web developer and I go by &lt;a href="https://twitter.com/yashguptaz"&gt;@yashguptaz&lt;/a&gt; on the internet. Be sure to direct message me on Twitter for any help you want.&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Understanding Git: Open Source for Novice.</title>
      <dc:creator>Yash</dc:creator>
      <pubDate>Tue, 05 May 2020 07:08:27 +0000</pubDate>
      <link>https://forem.com/yashguptaz/understanding-git-open-source-for-novice-58cj</link>
      <guid>https://forem.com/yashguptaz/understanding-git-open-source-for-novice-58cj</guid>
      <description>&lt;p&gt;Perhaps you hear the term "Open Source" often. You are impressed by people contributing to large complex Open Source Software. But you don't know where to start, even good first issues seem to be very hard to approach. &lt;/p&gt;

&lt;p&gt;I recently made a CLI Tool called &lt;a href="https://www.npmjs.com/package/tell-about"&gt;tell-about&lt;/a&gt; and open-sourced it. So as an open-source maintainer of my tool with little fame I got some experience so I have decided that I am going to help you understand how to contribute easily.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/yashguptaz"&gt;
        yashguptaz
      &lt;/a&gt; / &lt;a href="https://github.com/yashguptaz/tell-about"&gt;
        tell-about
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A CLI Tool that help you know about npm pacakges right in the command line.
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;So, what's the best way to start? &lt;/p&gt;

&lt;p&gt;I recently saw &lt;a href="https://twitter.com/benawad/status/1257379453757468673"&gt;a tweet by Ben Awad&lt;/a&gt; - &lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--BYSLznpk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1152793238761345024/VRBvxeCM_normal.jpg" alt="Ben Awad profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Ben Awad
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="mentioned-user" href="https://dev.to/benawad"&gt;@benawad&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      if you're a beginner and having a hard contributing to open source, I recommend starting your own project first then coming back to it
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      18:39 PM - 04 May 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1257379453757468673" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1257379453757468673" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1257379453757468673" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;I have to agree with it. I have decided to create a series of write-ups that help people understand the system of open-source software. The series is going to cover everything from introducing git to creating a fully automated repository on GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Git
&lt;/h2&gt;

&lt;p&gt;When I was a beginner, I always wondered what a pull request, a branch, and all those things were exactly. With all the complexity of git, it was hard for me to wrap my head around how everything in a complex project like React worked. &lt;/p&gt;

&lt;p&gt;Understanding how Git works is the first step to understanding how you can start to contribute to open-source software.&lt;/p&gt;

&lt;h3&gt;
  
  
  Need of Git
&lt;/h3&gt;

&lt;p&gt;For those who don't know, git is a VCS or Version Control System.  Now, take a moment to think about the version. There are &lt;em&gt;so many&lt;/em&gt; people trying to contribute to one single project.&lt;/p&gt;

&lt;p&gt;At a given time there are many people working on a single project but different features.&lt;/p&gt;

&lt;p&gt;If they all were to make changes directly to the project then there would be a huge mess,&lt;/p&gt;

&lt;p&gt;Let's try to understand with an example - 'A' changes lines 1 through 10 to incorporate a feature A and 'B' changes lines 5 through 15 to incorporate a feature B.&lt;/p&gt;

&lt;p&gt;'A' updates the code first. 'B' updates the code second.&lt;/p&gt;

&lt;p&gt;In this situation, the code of B works while the code of A is broken because B has now overwritten lines 5 through 10. Now take this example and magnify the situation with 25 people.&lt;/p&gt;

&lt;p&gt;Sure, they won't always be making changes on the same lines. But a lot of times they will be.&lt;/p&gt;

&lt;p&gt;This is where our VCS comes in to play. The VCS is used to maintain a main stable version. A stable version is a version where all features work properly.  This main stable version is generally called &lt;em&gt;Master&lt;/em&gt;. Let's learn about Branches to solve this issue.&lt;/p&gt;

&lt;h3&gt;
  
  
  Branches
&lt;/h3&gt;

&lt;p&gt;Let's now see how VCS solve this problem of merging two features.&lt;/p&gt;

&lt;p&gt;With git we can create a duplicate of the current Master version, this duplicate is called a branch. So, this time 'A' starts working on feature A on branch A. 'B' does the same.&lt;/p&gt;

&lt;p&gt;'A' makes the changes on branch A and merges their branch to the master version.&lt;/p&gt;

&lt;p&gt;Well and good.  Now, 'B' also tries to merge their branch but... we run into the same problem again except we have git to back it up. Git tells B that there is a merge conflict, B quickly identifies that A has made some changes and now he has a couple of options to resolve this merge conflict -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;He pulls (gets) the changes of A from the master branch to their branch, keeping the code of A, B adds their code after the code of A and keeps the code of both.&lt;/li&gt;
&lt;li&gt;While merging to the master branch B manually modifies the code to keep both feature A and feature B.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Generally, there will be a third person, a maintainer (or a senior) of the repository to regulate. The maintainer will review the code and ensure that B's code is good by reviewing it.&lt;/p&gt;

&lt;p&gt;More often than not, while contributing to big open source projects you will find that they also have tests. Tests checks if the output of code is as expected. And if any tests are failing it is fairly common to have a bot like &lt;a href="https://travis-ci.org/"&gt;Travis CI&lt;/a&gt; to tell if the code is broken. Which further mitigates the risk of breaking the code.&lt;/p&gt;

&lt;p&gt;So, in the scenario that A has some features and B breaks the feature the Travis CI bot will tell that tests of feature A is failed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Forks
&lt;/h3&gt;

&lt;p&gt;If you've used any amount of GitHub you must have noticed a fork button on GitHub repositories.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BkIkSQhx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bwlp4s6cnkzqiftvoz7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BkIkSQhx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bwlp4s6cnkzqiftvoz7g.png" alt="Fork Button on the top-right" width="880" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Branches are internal, even the master version I talked about is a branch, giving access to everyone to modify branches could be a big danger. That's where forks come in to play.&lt;/p&gt;

&lt;p&gt;When you create a fork of a repository you create a copy of that repository that belongs to you.&lt;/p&gt;

&lt;p&gt;The difference between Forks and branch is that when you create another branch it is the copy o f a branch. But when you create a fork it is a personal copy of the whole repository, you can modify it in any way you want and it won't effect the main codebase of the project.&lt;/p&gt;

&lt;p&gt;After you make changes to your fork you can request the maintainers of the project to merge your changes with the main project. That brings us to the next topic.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pull Requests
&lt;/h3&gt;

&lt;p&gt;Pull request might seem a bit complicated after you see it on GitHub. It may seem so complicated that you might neglect the simplicity of its name.&lt;/p&gt;

&lt;p&gt;A Pull Request is a request to the maintainers of a repository to pull (merge) your changes. Pull simply means pulling changes from your fork or branch to another branch which is the master branch most of the time. A request is a request.&lt;/p&gt;

&lt;p&gt;A Pull Request compares 2 branches, the 2 branches maybe master branch and a branch from your fork or master branch with any other branch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JZ2519Dp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0kmp2excsenp6182q8wk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JZ2519Dp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0kmp2excsenp6182q8wk.png" alt="Comparing two branches in git" width="511" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Ending Note
&lt;/h2&gt;

&lt;p&gt;Hopefully, this blog post gives you a really good way to start comprehending the working of git in open source projects. In my upcoming posts, I will be covering how you can contribute and even set up your own fully automated open source project on GitHub.&lt;/p&gt;

&lt;p&gt;Thanks for reading till the end :)&lt;/p&gt;

&lt;p&gt;Make sure to follow me on &lt;a href="http://dev.to/yashguptaz"&gt;dev.to&lt;/a&gt; so that you're updated about my upcoming posts.&lt;/p&gt;

&lt;p&gt;I am active on &lt;a href="https://twitter.com/yashguptaz"&gt;Twitter&lt;/a&gt; and I am known by the username &lt;a class="mentioned-user" href="https://dev.to/yashguptaz"&gt;@yashguptaz&lt;/a&gt;. Be sure to hit me up on Twitter if you want any help. A follow-on Twitter is really appreciated :)&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>yashguptaz</category>
    </item>
    <item>
      <title>🍛 What the heck is Currying? ft. JavaScript</title>
      <dc:creator>Yash</dc:creator>
      <pubDate>Wed, 18 Mar 2020 08:23:54 +0000</pubDate>
      <link>https://forem.com/yashguptaz/what-the-heck-is-currying-ft-javascript-jlp</link>
      <guid>https://forem.com/yashguptaz/what-the-heck-is-currying-ft-javascript-jlp</guid>
      <description>&lt;p&gt;I know that you’re salivating, perhaps the dev world has become too delicious with JAMStack and now I’m talking about curry? So before you starve to death with these wonders of dev world let me introduce you to what currying is in general.&lt;/p&gt;

&lt;p&gt;Currying was named after &lt;a href="https://en.wikipedia.org/wiki/Haskell_Curry"&gt;Haskell Curry&lt;/a&gt;, what currying essentially means is taking a function that takes multiple parameters and converting it into a function which only takes one parameter and returns a function which then takes the next parameter.&lt;/p&gt;

&lt;p&gt;Currying is not JavaScript specific it is also a mathematical thing just like &lt;code&gt;function&lt;/code&gt; (Remember good ol' f(x) ?)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Not curried&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;

&lt;span class="c1"&gt;// Curried&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addFive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;addFive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 11&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see using Currying we were able to have functions that are more definite in what they do, this in turn greatly simplifies our code.&lt;/p&gt;

&lt;p&gt;With the help of currying, we can essentially pre-load functions with an argument in order to receive a new function that remembers those arguments.&lt;/p&gt;

&lt;p&gt;Let's make a function that can help us in Currying other functions.&lt;br&gt;
Now pay close attention,&lt;br&gt;
This function is going to take a function &lt;code&gt;fn&lt;/code&gt; and return a function &lt;code&gt;$curry&lt;/code&gt; that takes a single argument and performs the operation of the function &lt;code&gt;fn&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's do this step by step&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This function takes a function `fn` as a parameter.&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Let us determine the arity of `fn`&lt;/span&gt;
  &lt;span class="c1"&gt;// Arity is the number of parameter taken by `fn`&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;

  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="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;curry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&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;arity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;

  &lt;span class="c1"&gt;// Let's return the $curry function.&lt;/span&gt;
  &lt;span class="c1"&gt;// Let's have all the arguments ( ...args ) being passed in $curry&lt;/span&gt;
  &lt;span class="c1"&gt;// Remember we are returning a function so we can pass args in it.&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;$curry&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&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;div class="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;curry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&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;arity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;$curry&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Let's return the function with all the passed arguments.&lt;/span&gt;
    &lt;span class="c1"&gt;// This code maybe stupid until you read the next para...&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;$curry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&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;We can't just keep returning functions and functions we need a result. Let it be adding digits together and getting the output.&lt;/p&gt;

&lt;p&gt;Let's add a condition for this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;curry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&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;arity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;$curry&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&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;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arity&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="nx"&gt;$curry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;args&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="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;args&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;By comparing the length of the arguments &lt;code&gt;args.length&lt;/code&gt; we can know how many arguments have been passed in the function.&lt;/p&gt;

&lt;p&gt;Things will become more clear as I demonstrate how we are using the &lt;code&gt;curry&lt;/code&gt; function to curry other functions which take multiple parameters.&lt;/p&gt;

&lt;p&gt;For the sake of simplicity let's take an &lt;code&gt;add&lt;/code&gt; function which takes 3 values (parameters) and add them together.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;curriedAdd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;add&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;addFive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;curriedAdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// args.length = 1&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addFiveAndSix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;addFive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// args.length = 2&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;addFiveAndSix&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="c1"&gt;// args.length = 3&lt;/span&gt;

&lt;span class="c1"&gt;// The funciton can be called now as `args.length` &amp;lt; arity is false.&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;output&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 19&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;args.length&lt;/code&gt; is able to give us the number of arguments because of &lt;code&gt;return $curry.bind(null, ...args)&lt;/code&gt; . The &lt;code&gt;$curry&lt;/code&gt; function contains all the arguments passed above the any given instance.&lt;/p&gt;

&lt;p&gt;I hope this clears everything about how the function is working. If you have any other doubts you can tweet them to me.&lt;/p&gt;

&lt;p&gt;( @&lt;a href="https://twitter.com/yashguptaz"&gt;yashguptaz&lt;/a&gt; )&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Taste to your Code.
&lt;/h2&gt;

&lt;p&gt;Currying allows a wonderful phenomenon called partial application.&lt;br&gt;
According to Wikipedia partial application can be defined as -&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Partial Application refers to the process of fixing a number of arguments to a function, producing another function of smaller arity.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The definition is pretty straightforward, we reduce the number of parameters a function takes by currying it.&lt;/p&gt;

&lt;p&gt;Let's &lt;code&gt;curry&lt;/code&gt; a well-known function &lt;code&gt;map&lt;/code&gt; and see how it changes our life.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Before Currying&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allTheChildren&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;elements&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getChildren&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Let's curry map&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;f&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="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;// AFter Currying&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allTheChildren&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;getChildren&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The effect becomes really obvious when you are using &lt;code&gt;map&lt;/code&gt; multiple times. And that's how we reduce a ton of boilerplate code.&lt;/p&gt;

&lt;p&gt;You can curry pretty much any function that takes more than one parameter. And use Partial Application.&lt;/p&gt;

&lt;p&gt;Isn't it amazing? Although I am a beginner at currying I found it exciting to share. If you want to share something or ask a question or would like to solve or understand something together, you can hook me up on twitter. I am &lt;a href="https://twitter.com/yashguptaz"&gt;@yashguptaz&lt;/a&gt; on the internet.&lt;/p&gt;

&lt;p&gt;Follow me on twitter as I tweet about my experince with Functional Programming.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>currying</category>
      <category>functional</category>
      <category>programming</category>
    </item>
    <item>
      <title>Quality Server-Side Rendering with React</title>
      <dc:creator>Yash</dc:creator>
      <pubDate>Sun, 22 Dec 2019 04:43:09 +0000</pubDate>
      <link>https://forem.com/yashguptaz/quality-server-side-rendering-with-react-57jk</link>
      <guid>https://forem.com/yashguptaz/quality-server-side-rendering-with-react-57jk</guid>
      <description>&lt;p&gt;Server-side rendering is a term that we often hear in the react world, there are a lot of frameworks that help us with server-side rendering like Next.js and Gatsby. Server-side rendering can add various additional improvements to our application but at the same time complicate things even more. There are situations where it is useful and other situations where it can cause trouble.&lt;/p&gt;

&lt;p&gt;When I first heard the term server-side rendering I thought it had something to do with the backend of the application, but it turned out it was something totally different than that.&lt;/p&gt;

&lt;p&gt;We will start by comparing how does loading and rendering a website differ in the client-side rendering and server-side rendering.&lt;/p&gt;

&lt;h3&gt;
  
  
  Loading Application while Client-Side Rendering it
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;JavaScript, CSS, and other Libraries are loaded.&lt;/li&gt;
&lt;li&gt;ReactDOM.render() starts.&lt;/li&gt;
&lt;li&gt;Fetching of data is started and requests are sent, the application gets the data from external APIs.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;The whole Virtual DOM is created. It gets reconciled with the real DOM. React traverses the whole Virtual DOM and renders it to the real DOM.&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The issue with client-side rendering is that this process takes a very long time. That's where server-side rendering comes in to play.&lt;/p&gt;

&lt;p&gt;In server-side-rendering instead of initially creating the Virtual DOM, we send an HTML element initially rendered instead. This is  usually done by &lt;a href="https://reactjs.org/docs/react-dom-server.html#rendertostring"&gt;ReactDOMServer.renderToString()&lt;/a&gt; method.&lt;/p&gt;

&lt;p&gt;We avoid the process of loading the Virtual DOM and reconciling it with the real DOM instead we put HTML directly into our DOM with server-side rendering.&lt;/p&gt;

&lt;p&gt;Although there are few things that we can do to optimize the performance of a client-side rendered application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Optimizing Client-side rendered application
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Load the layout or the skeleton part first.&lt;/li&gt;
&lt;li&gt;Cache the skeleton part with service workers.&lt;/li&gt;
&lt;li&gt;Show a certain part of the layout even if the majority part of the layout is dynamically added like the top navbar which has a login button.&lt;/li&gt;
&lt;li&gt;You can avoid loading the dynamic parts of the application initially.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For the sake of user experience please always load the skeleton first, if the height or width is not fixed with the element please load it at the last.&lt;/p&gt;

&lt;p&gt;When using Twitter to search users it always shifts the user being displayed below after it completely loads and whenever I am about to click I click the wrong place.&lt;/p&gt;

&lt;p&gt;This is a terrible practice and should be avoided.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dependencies are better pre-loaded with Server Side Rendering
&lt;/h3&gt;

&lt;p&gt;Say we use some dependency A in our application using which triggers the fetch of dependency B.&lt;/p&gt;

&lt;p&gt;With client-side rendering, one has to fetch dependency A and then B which is slow.&lt;/p&gt;

&lt;p&gt;With server-side rendering, you can present your application with dependency A and avoid fetching an extra dependency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Better SEO with Server Side Rendering
&lt;/h3&gt;

&lt;p&gt;Server-Side Rendering makes crawlers easy to crawl pages. Google indexes the page with HTML faster than those with JavaScript rendering DOM elements. &lt;/p&gt;

&lt;p&gt;This is because people can easily trick google having a lot of text with JavaScript but in actuality, when they render the page they have a very little amount of relevant text which can also be used to mislead people. So indexing pages that render with the help of JavaScript is tricky which is why people use Server Side Rendering for better SEO.&lt;/p&gt;

&lt;h3&gt;
  
  
  Trade-offs of Server-Side Rendering
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Maintainability Nightmare: You need to maintain 2 DOM trees.&lt;/li&gt;
&lt;li&gt;Some libraries are not aware of server-side rendering so they make an assumption about the presence of window objects which can sometimes, make the library unusable.&lt;/li&gt;
&lt;li&gt;The complexity starts to increase exponentially with a server-side rendered application as they don't have access to the window object, things like local storage are not present so complexity increases with data and state management.&lt;/li&gt;
&lt;li&gt;React itself is not very server-side compatible.&lt;/li&gt;
&lt;li&gt;Time-to-interaction is very high with server-side rendering. This is because HTML is loaded faster than JavaScript. So there might be cases where user is unable to click a button when it is loaded.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Server-side rendering is best suited for parts of the application that do not require dynamic interactions.&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href="https://twitter.com/_syadav"&gt;Sudhanshu Yadav&lt;/a&gt;. He helped me with much of the content of the blog. Please do follow him on Twitter.&lt;/p&gt;

&lt;p&gt;If you have any opportunities for me or want to connect to me with &lt;a href="https://twitter.com/yashguptaz"&gt;Twitter&lt;/a&gt;, I am &lt;a class="mentioned-user" href="https://dev.to/yashguptaz"&gt;@yashguptaz&lt;/a&gt; on the internet.&lt;/p&gt;

&lt;p&gt;Thanks for Reading.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>ssr</category>
    </item>
  </channel>
</rss>
