<?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: Rakesh</title>
    <description>The latest articles on Forem by Rakesh (@rakesh).</description>
    <link>https://forem.com/rakesh</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%2F516661%2F034b2eee-6523-4084-b5f7-a843f604e467.jpg</url>
      <title>Forem: Rakesh</title>
      <link>https://forem.com/rakesh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rakesh"/>
    <language>en</language>
    <item>
      <title>Demystifying DOM(s) : Everything you need to know about DOM, V-DOM, Shadow DOM</title>
      <dc:creator>Rakesh</dc:creator>
      <pubDate>Sat, 26 Dec 2020 09:46:06 +0000</pubDate>
      <link>https://forem.com/rakesh/demystifying-dom-s-everything-you-need-to-know-about-dom-v-dom-shadow-dom-cdj</link>
      <guid>https://forem.com/rakesh/demystifying-dom-s-everything-you-need-to-know-about-dom-v-dom-shadow-dom-cdj</guid>
      <description>&lt;h2&gt;
  
  
  Back Story
&lt;/h2&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608834894870%2FMBXSOxwkW.jpeg" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608834894870%2FMBXSOxwkW.jpeg" alt="ff77ad5b8bbae0f06f8be250129a6b6981984ef3.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wondering why this picture ?&lt;/p&gt;

&lt;p&gt;Because if you have asked me about DOM few months back , I would have told you about him. As he is the only "Dom" I knew, till I started learning web dev at neoG Camp. &lt;/p&gt;

&lt;p&gt;In our third week at neoG Camp, I got introduced to another DOM formally by our mentor .Although it was just enough intro to work upon the assignment , I got more confused when virtual DOM is introduced in our fourth week . And when I heard that there is something called shadow DOM too , I could not stop myself to dive deeper.&lt;/p&gt;

&lt;p&gt;Here is what I am able to understand about DOM(s) .&lt;/p&gt;

&lt;h2&gt;
  
  
  What is this DOM ?
&lt;/h2&gt;

&lt;p&gt;DOM or Document Object Model  is a web api that models the entire html document in an object oriented way , so that programming languages like Javascript can access and manipulate it's properties .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because without representing the elements of html document as objects, Javascript won't be able to recognise them,let alone accessing it's properties .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By taking all the elements of the doument as objects and then representing them in a hierarchical tree . In that tree each branch starts and ends with nodes and by using these nodes javascript control the whole document .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;so only elements are represented as nodes ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not Necessarily . A node is just the generic name for any type of object in DOM tree .&lt;br&gt;
It could be one of the built-in DOM element like &lt;code&gt;document&lt;/code&gt; or &lt;code&gt;document.body&lt;/code&gt; or it could be an element node or text node or even attribute node too . &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;so if it's all objects underneath , why updating it slow ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Actually updating the DOM is not slow , It's like updating any javascript object . It's what comes after the manipulation that's where the problem lies . So in order to answer what is making the whole process slow we need to understand browser workflow first .&lt;/p&gt;

&lt;h3&gt;
  
  
  Broswer Workflow
&lt;/h3&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608815676993%2Fd88UhZuMR.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608815676993%2Fd88UhZuMR.png" alt="flow.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the above image , you can see it's happening in four stages mainly .&lt;br&gt;
But you must be thinking who is responsible for all of it . The answer is "Rendering Engine" .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Rendering Engine&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Like the name suggests, all it does is Render, that is displaying requested contents on the browser screen. Below we are going to see the work flow of webkit engine that powers browsers like safari ,chrome and edge . &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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608815266535%2FEGa_g_uzs.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608815266535%2FEGa_g_uzs.png" alt="webkitflow.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see from the above image before painting each modification it has to go through all those time consuming stages like layout and paint . &lt;/p&gt;

&lt;p&gt;So for example if you have modified 40 nodes, one by one. That would mean 40 potential re-calculations of the layout, 40 potential tree modifications and 40 potential re-renderings too .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And that's what makes it look like direct DOM Manipulation slow .&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's like creating your bike from scratch for every little fix or color change or even stickering . Then imagine if you have to do the same thing for a BUS .&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608832808880%2F0FUDecF2v.jpeg" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608832808880%2F0FUDecF2v.jpeg" alt="seriously-thats-insane.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yes it's insane ,  If you are even thinking about creating something like facebook and twitter in this way .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;then solution ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Virtual DOM a.k.a VDOM . &lt;/p&gt;

&lt;p&gt;Although it is not the only way we can address this issue , We are going to talk about this only .&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608834732364%2FSIfY2XfCD.jpeg" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608834732364%2FSIfY2XfCD.jpeg" alt="virtual_dom_1200.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Virtual DOM
&lt;/h2&gt;

&lt;p&gt;Virtual DOM is nothing but a light-weight copy of actual DOM that exist only in memory . Like actual DOM it is a object too . You can think of it as a blueprint to the actual thing .&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608881491601%2F897OFqcEF.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608881491601%2F897OFqcEF.png" alt="pasted image 0.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  then how does it different from actual DOM?
&lt;/h3&gt;

&lt;p&gt;It lacks the ability to directly change what is displayed on the screen until the real DOM is updated . Which is why, it does not have to go through all the heavy weight stages like re-layout or re-paint etc . It just observes the changes then draws out in blueprint and passes it down to the real DOM .&lt;/p&gt;

&lt;p&gt;Sounds fascinating , right ? Even if it's not ..can u please pretend and ask something like below question.. &lt;/p&gt;

&lt;h3&gt;
  
  
  how does it do it ?
&lt;/h3&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608883753351%2FXaJjxA6x6.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608883753351%2FXaJjxA6x6.png" alt="1_wrh_lW6mpQHRsuGtw1FuqA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see from above pictures , the whole process can be divided broadly into three parts .&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;State Change&lt;/strong&gt; -  Due to changing state of red color node , virtual DOM is generated in memory with the updated tree .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compute diff&lt;/strong&gt; - Comparison is carried out to detect the changes and it's effects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Re-render&lt;/strong&gt; - Finally , the change in real DOM is consolidated and updated at once.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's get to the million dollar question..&lt;/p&gt;

&lt;h3&gt;
  
  
  How does react use it to solve our problem ?
&lt;/h3&gt;

&lt;p&gt;In short , by using following things :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Observable instead of dirty checking to detect the change&lt;/li&gt;
&lt;li&gt;Efficient diff algorithm&lt;/li&gt;
&lt;li&gt;Batched update operations&lt;/li&gt;
&lt;li&gt;Efficient update of subtree only&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using observable's instead of dirty checking&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In React, each piece of the UI is a component and each component has an internal state. This state is observed by the library in order to detect changes in it. So whenever state changes , React mark that component dirty and re-renders it.&lt;/p&gt;

&lt;p&gt;So unlike angular that uses dirty checking to find modified models in regular intervals , React uses observables to find the exact modified components . If there are no state changes then it won't have to do anything .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Diffing Algorithm&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before rendering a new component , React must figure out the specific parts that need to be updated . And to figure out this React must compare between two Virtual DOMs it maintains at any given time , one with the updated state and the other with previous state .&lt;/p&gt;

&lt;p&gt;And To achieve it efficiently , React uses a heuristic approach known as the Diffing Algorithm of the order O(n) instead of using state of the art algorithm of order [O(n³)] .&lt;/p&gt;

&lt;p&gt;&lt;em&gt;HOW&lt;/em&gt; ? by  relying on below assumptions ..&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Assumption 1 :&lt;/em&gt;  Two elements of different types will produce two different trees.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Assumption 2 :&lt;/em&gt;  The developer can hint at which child elements may be stable across different renders with a key prop.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Batch Update operations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React uses the diffing process to find minimum no. of steps to update the Real DOM and once it has those , it executes all of it in one event loop . So if there are more elements that needs to get updated in meantime , React will wait for the event loop to finish first and then in bulk will update the DOM with updated elements . &lt;/p&gt;

&lt;p&gt;After all these steps are done, React will repaint the Real DOM .&lt;/p&gt;

&lt;p&gt;As you can see DOM is getting repainted only once during the whole process, thus all the layout , re-calculation process will run only once .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Updating the subtree only&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ReactJS traverses the tree using BST. So if the state of a component has changed, then ReactJS re-renders all the child components even if they are not modified .&lt;/p&gt;

&lt;p&gt;Consider the tree below.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608922342181%2FYQSn7jFep.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608922342181%2FYQSn7jFep.png" alt="1_YYHCZn-Bxkf-kY_TGgp8wA.png"&gt;&lt;/a&gt;&lt;br&gt;
States of element B and H have changed. So when using BST ReactJS reached element B it will by default re-render the element H. This is the reason to use BST for tree traversal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is shadow DOM is same as Virtual DOM ?
&lt;/h3&gt;

&lt;p&gt;NO..they are completely different things..&lt;/p&gt;

&lt;h2&gt;
  
  
  Shadow DOM
&lt;/h2&gt;

&lt;p&gt;Shadow DOM refers to the ability of the browser to include a subtree of DOM elements into the rendering of a document, but not into the main document DOM tree. &lt;/p&gt;

&lt;p&gt;you can say it simply as “ DOM within a DOM” .&lt;/p&gt;

&lt;p&gt;As it remains hidden and separate from the scope of the other codes , we use it as a meanning of creating web component .&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608934346730%2FMvwBfxqx6.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608934346730%2FMvwBfxqx6.png" alt="0_66kSmyuCNeD7Oiaq.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can you give a example that we know ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;think of &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element with all it's default controls . For us it maybe&lt;br&gt;
just &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element that we can put anywhere in our document without any hassle.&lt;/p&gt;

&lt;p&gt;But if you look closely in it's shadow DOM , you are gonna find out a series of buttons , controls and other settings hidden and separated from the outer code .&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How did I remove the rate limit from my minion translator and how you can do it too : a neogCamp story</title>
      <dc:creator>Rakesh</dc:creator>
      <pubDate>Mon, 21 Dec 2020 15:59:37 +0000</pubDate>
      <link>https://forem.com/rakesh/how-did-i-remove-the-rate-limit-from-my-minion-translator-and-how-you-can-do-it-too-a-neogcamp-story-2kgp</link>
      <guid>https://forem.com/rakesh/how-did-i-remove-the-rate-limit-from-my-minion-translator-and-how-you-can-do-it-too-a-neogcamp-story-2kgp</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;For those who don't know what I am talking about , Neog Camp is a project oriented bootcamp under the supervision of tanay pratap , where you can only advance to the Level ONE, if you have finished all the assignments from Level ZERO .&lt;/p&gt;

&lt;p&gt;And Minion Translator is one of those assignment in which, we have to use the fun translation api to translate from english to minionese .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;so what's the problem ?&lt;/strong&gt;&lt;br&gt;
The problem is rate limiting . &lt;/p&gt;
&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Fun translation or similar public apis ratelimit the api calls to maintain their server level.So you can imagine the problems that can arise if 500 folks uses the same api that accepts only 5 calls per hour .&lt;/p&gt;

&lt;p&gt;And not only it was causing problem during the devlopment, it was gonna be there even after the deployment too. Imagine sharing your app to your friends or employers and all they get is &lt;code&gt;error occured ! try after sometime&lt;/code&gt; message .&lt;/p&gt;
&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;There was only two possible solutions to these problems and they were&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Finding another API that is free and unlimited&lt;/li&gt;
&lt;li&gt;Building your own API&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I choose the second option after wasting a day in search for the first one .&lt;br&gt;
Before that I have known about APIs in theories only, never used one of them not even a mock one before Neog Camp tutorial. But still somehow It seems feasible after using the Mock Server created by Tanay Pratap . &lt;/p&gt;

&lt;p&gt;He have already taken care of the input and output part of the program, so all I have to do was figure out the processing part . When I thought about the inner-workings of fun translation API, It seems like all it was doing underneath is taking our values , comparing it to values in the database and returning whatever the corresponding values as result and If something is not on the database it returns the same.&lt;/p&gt;

&lt;p&gt;So first of all I needed to find a database of minion words and thanks to the popularity of minion it was not that hard. I found a extreme large list of minionese words compiled by Bryce Dorn and available under MIT license in github .&lt;/p&gt;

&lt;p&gt;After getting the database all I had to do was write a program that can map through the list and compared the input to the words in the list . As we all have done similar program in our second CLI app , I tried similar approach here too . But only could translate single words even after a lot of attempt . So I took the help from our mentors Rohit Gaur and Sreetam Das and Voila , our own api was ready .&lt;/p&gt;

&lt;p&gt;Now only one more thing was left that is finding a way to keep it running forever . Which was taken care by Repl.it very efficiently as once deployed, the HTTP Server will continue to run in the background, even after you close the browser tab .&lt;/p&gt;

&lt;p&gt;you can read more about it from &lt;a href="https://docs.repl.it/repls/http-servers" rel="noopener noreferrer"&gt;here&lt;/a&gt;  .&lt;/p&gt;
&lt;h2&gt;
  
  
  End Result
&lt;/h2&gt;

&lt;p&gt;I have used it in my own minion translator app . so you can test it  &lt;a href="https://minionsarelove.netlify.app/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes it may take some time waking a idle server which can be fixed by a quick refresh but normally you won't need it . &lt;/p&gt;
&lt;h1&gt;
  
  
  How can you use it in your own app ?
&lt;/h1&gt;
&lt;h3&gt;
  
  
  Step one
&lt;/h3&gt;

&lt;p&gt;Go to the below link and fork the repl&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; https://repl.it/@r4k3sh/minionsapi#index.js

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

&lt;/div&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608559686536%2FfMvvJqLKT.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608559686536%2FfMvvJqLKT.png" alt="NEUQY95qIL.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step Two
&lt;/h3&gt;

&lt;p&gt;Run the Repl &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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608559755324%2F9zrLLyRH6.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608559755324%2F9zrLLyRH6.png" alt="mFC1vNxyZj.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step Three
&lt;/h3&gt;

&lt;p&gt;Grab the link it provide &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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608560450203%2FXhs6wtrz_.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608560450203%2FXhs6wtrz_.png" alt="r5gDcWxcHD.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;add &lt;code&gt;/translate/minion.json?text=&lt;/code&gt; to it &lt;/p&gt;

&lt;p&gt;so for me it becomes :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://minionsapi.r4k3sh.repl.co/translate/minion.json?text=
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will have similar links based on your repl name and id .&lt;/p&gt;

&lt;h3&gt;
  
  
  Step Four
&lt;/h3&gt;

&lt;p&gt;Test the api on browser after typing anything after the above url .&lt;/p&gt;

&lt;p&gt;If everything goes well you will receive the translated text instantly like below .&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608561316330%2FdHuXKat05.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608561316330%2FdHuXKat05.png" alt="XyboJ8JY9n.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step Five
&lt;/h3&gt;

&lt;p&gt;Replace the link in your app instead of fun translation api url .&lt;/p&gt;

&lt;p&gt;Similarly you can make any other translation API too ,If you can manage to find the wordlist.&lt;/p&gt;

&lt;p&gt;That's it neoGrammers .&lt;/p&gt;

&lt;p&gt;Thank you.&lt;/p&gt;

&lt;h2&gt;
  
  
  CREDITS
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://bryce.io/" rel="noopener noreferrer"&gt; Bryce Dorn&lt;/a&gt;: For Compiling the Word list &lt;/p&gt;

&lt;p&gt;&lt;a href="https://tanaypratap.com/" rel="noopener noreferrer"&gt; Tanay Pratap&lt;/a&gt;:  For Creating the Server&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sreetamdas.com/" rel="noopener noreferrer"&gt;Sreetam Das&lt;/a&gt; &amp;amp;  &lt;a href="https://rohit.xyz/" rel="noopener noreferrer"&gt;Rohit Gaur&lt;/a&gt;:  For Writing the final piece of code &lt;/p&gt;

&lt;p&gt;&lt;a href="https://neog.camp/" rel="noopener noreferrer"&gt; Neog Camp &lt;/a&gt;: For Existing&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Getting started with Eloquent Javascript : Chapter one summary</title>
      <dc:creator>Rakesh</dc:creator>
      <pubDate>Sun, 06 Dec 2020 15:29:57 +0000</pubDate>
      <link>https://forem.com/rakesh/getting-started-with-eloquent-javascript-chapter-one-summary-5279</link>
      <guid>https://forem.com/rakesh/getting-started-with-eloquent-javascript-chapter-one-summary-5279</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;“Below the surface of the machine, the program moves. Without effort, it expands and contracts. In great harmony, electrons scatter and regroup. The forms on the monitor are but ripples on the water. The essence stays invisibly below.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;— Master Yuan-Ma, The Book of Programming&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;If we deep dive into the computer's world , we  are going to findout it's all Data in there , It always has been . So if something is not Data neither we can use it nor mention it within computers .It's important to remember here every Data is fundamentally same as they are all stored in long sequence of Bits .&lt;/p&gt;

&lt;p&gt;so you must be thinking what are these Bits..so let's talk about it .&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Bits ?
&lt;/h1&gt;

&lt;p&gt;Although we usually describe it as ones and zeros it can take any forms like high or low electrical charge , a strong or weak signal etc .&lt;/p&gt;

&lt;p&gt;If any form of information can be reduced to a sequence of zeros and ones, It can be represented in Bits .&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Fun Fact :  Modern computers have more than 30 million bits in its volatile memory itself .  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  How can a human work with this ocean of bits without getting lost in them ?
&lt;/h1&gt;

&lt;p&gt;The answer is Divide and Conquer . We group them according to their type so that they can represent  particular pieces of information according to their role .&lt;/p&gt;

&lt;p&gt;These chunks of Bits are also known as Values and they can be of different types like functions, text , number etc .&lt;/p&gt;

&lt;h1&gt;
  
  
  So how do we create those values and use it according to our requirement ?
&lt;/h1&gt;

&lt;p&gt;All you have to do is call it ..or you can say invoke its name and voila , you will have it .&lt;/p&gt;

&lt;p&gt;One thing we must keep in mind while using Values is, every one of them is getting stored somewhere in memory and that is memory is limited . &lt;/p&gt;

&lt;p&gt;So if you are not needing them simultaneously there should not be any problems as values will disipate as soon as you stop needing them .&lt;/p&gt;

&lt;h1&gt;
  
  
  Different Types of Values
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Numbers
&lt;/h2&gt;

&lt;p&gt;As you can guess from the name, values of this type are numeric values like &lt;code&gt;13,15,100&lt;/code&gt; etc. As javascript uses a fixed number of bits i.e 64 bits to represent Numbers, there is a certain limit to the number of different numbers we can represent, although that limit is about 18 quintillion.&lt;/p&gt;

&lt;p&gt;There is something important here to remember that not only whole numbers but also negative(like &lt;code&gt;-13 or -20&lt;/code&gt;) and fractional numbers (like &lt;code&gt;5.2 or 2.99e8&lt;/code&gt; ) are there too, to be represent by the same 64 bits pattern .&lt;/p&gt;

&lt;p&gt;However calculations involving with fractional numbers are generally not precise like it's with whole numbers . &lt;/p&gt;

&lt;p&gt;which lead us to the main thing that numbers do, that is arithamtic operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arithmatic Operations&lt;/strong&gt;&lt;br&gt;
It basically take two numbers , perform some operations with the help of operator like &lt;code&gt;'+' ,'-', '*' ,'/', '%'&lt;/code&gt;and return another number .&lt;/p&gt;

&lt;p&gt;The order in which the operations are going to be executed is decided by Operator Precedence. Most of the time they follow the BODMAS rule generally .&lt;/p&gt;

&lt;p&gt;for example : &lt;code&gt;100+10*45 = 550&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can always change the precendce by wrapping the operands in parantheses .&lt;/p&gt;

&lt;p&gt;for example : &lt;code&gt;(100+10)*45 = 4950&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Fun Fact :  There is a difference between modulo(&lt;code&gt;'%'&lt;/code&gt;) and &lt;br&gt;
   remainder (&lt;code&gt;'%'&lt;/code&gt;).Remainder can be negative but modulo is &lt;br&gt;
   always positive.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Special Numbers&lt;/strong&gt;&lt;br&gt;
There are three special values are there too in javascript which are considered as numbers but don't behave a like a normal one .&lt;/p&gt;

&lt;p&gt;They are &lt;code&gt;iInfinity&lt;/code&gt; ,&lt;code&gt;-Infinity&lt;/code&gt; and &lt;code&gt;NaN&lt;/code&gt; ( stands for "not a number") .&lt;/p&gt;
&lt;h2&gt;
  
  
  Strings
&lt;/h2&gt;

&lt;p&gt;After Number strings are the next common data types , which are mainly used to represent text . If we want anything to be perceived as strings, we must wrap them around in quotes .&lt;/p&gt;

&lt;p&gt;It can be single quotes,double quotes or backticks .Take a look at below examples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   `Down on the sea`
   "Lie on the ocean"
   'Float on the ocean'

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

&lt;/div&gt;



&lt;p&gt;so you must be thinking why are using backticks ? &lt;/p&gt;

&lt;p&gt;Because when required they can embed other values too .&lt;br&gt;
let's have a look at below example &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;half of 100 is ${100 / 2}&lt;/code&gt; // "half of 100 is 50"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;you can see when we write something inside &lt;code&gt;${}&lt;/code&gt;within  a backtick, the results will be computed first before converting into a string.They are known as Template Literals .&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Fun Fact :  we can use &lt;code&gt;'+'&lt;/code&gt; on strings which concatenates or glues them together .&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Boolean Values
&lt;/h2&gt;

&lt;p&gt;Javascript has a Boolean data type which only has just two values i.e true or false .  It is very useful in controlling the program flow when using conditional statements like if..else .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(3 &amp;gt; 2) // true
console.log(3 &amp;lt; 2) // false
console.log(NaN == NaN) // false

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Fun fact : &lt;code&gt;NaN&lt;/code&gt; is only value in js that is not equal to itself.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Empty values
&lt;/h2&gt;

&lt;p&gt;You may have known them as &lt;code&gt;undefined&lt;/code&gt; or &lt;code&gt;null&lt;/code&gt; . These values are only used in the absence of meaningful value . &lt;/p&gt;

&lt;p&gt;Generally &lt;code&gt;undefined&lt;/code&gt; means the variable or the memory location is not defined or instantiated but &lt;code&gt;null&lt;/code&gt; however means lack of a value , however you can use them interchangeable as it does not matter most of the time .&lt;/p&gt;

&lt;h2&gt;
  
  
  Operators
&lt;/h2&gt;

&lt;p&gt;Operators are normally special symbols which are used to perform operations on values or variables a.k.a Operands . But not all operators are symbols some are written as words too . &lt;/p&gt;

&lt;p&gt;for example &lt;code&gt;type of&lt;/code&gt; operator . It is also known as unary operator as it only operates on one value .&lt;/p&gt;

&lt;p&gt;for example :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;console.log(typeof 6 )&lt;/code&gt; // Number&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are also Binary and Ternary operators too , which operates on two or three operands respectively .&lt;/p&gt;

&lt;p&gt;Binary operators examples : &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;console.log (6 + 3)&lt;/code&gt; // 9&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ternary operator syntax :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;(conditon) ? statement-if-true: statement-if-false.&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;So we have discused briefly about various types of javascript values and operators that can transform them . But if you want to know more about them you can read it from &lt;a href="https://eloquentjavascript.net/01_values.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you ..&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>books</category>
      <category>programming</category>
    </item>
    <item>
      <title>How does javascript really work : a peek under the hood..</title>
      <dc:creator>Rakesh</dc:creator>
      <pubDate>Tue, 24 Nov 2020 13:35:26 +0000</pubDate>
      <link>https://forem.com/rakesh/how-does-javascript-really-work-a-pick-under-the-hood-4kb2</link>
      <guid>https://forem.com/rakesh/how-does-javascript-really-work-a-pick-under-the-hood-4kb2</guid>
      <description>&lt;p&gt;Javascript can be found everywhere nowadays ,from browser to server, from mobile to desktop, even in hybrid apps as well. Also It has a vast community behind it with an equally incredible eco-system which is contineously evolving  in a proper way .&lt;/p&gt;

&lt;p&gt;All of this led it to become one of the most preferred language to learn for newbies like me for getting a job in near future . But a lot of us never try to find out how it is actually working behind the scene , unless they have a interview scheduled next week .&lt;/p&gt;

&lt;p&gt;That's why this article is an attempt to give everyone a heads up about the basics ..so without further ado ..let's get going then..&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Have you ever thought how come all the modern browsers understand javascript  ? who is translating it for them ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;They all have something similar...A Javascript Engine built into them...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Is Javascript Engine now ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Javascript Engine nothing but a program written normally in C and C++ , which goes through the javascript code one line at a time and convert it to the machine readable format so that the cpu can understand and execute it .&lt;/p&gt;

&lt;p&gt;Some famous javascript engines are : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; V8 – engine used in Opera &amp;amp; Chrome.&lt;/li&gt;
&lt;li&gt; SpiderMonkey – engine used in Firefox.&lt;/li&gt;
&lt;li&gt; SquirrelFish – engine used in Safari.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Ok, So What's in this Engine  ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is mainly consist of two main parts :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory Heap&lt;/li&gt;
&lt;li&gt;Call Stack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8Vy1p7bQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606155215227/crNv-MLAc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8Vy1p7bQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606155215227/crNv-MLAc.png" alt="js engine.png" width="756" height="657"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are those now ?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Memory Heap&lt;/em&gt;&lt;/strong&gt;- Whenever you define a variable, constant, &lt;br&gt;
object,etc in your javascript program, you need some place to &lt;br&gt;
store it first , That place is nothing but the memory heap.&lt;/p&gt;

&lt;p&gt;So Whenever we define a variable like&lt;code&gt;var a = 10&lt;/code&gt;, a &lt;br&gt;
location in the memory is assigned to store the value of a.&lt;/p&gt;

&lt;p&gt;However there is something important here to remember , the &lt;br&gt;
available memory in Memory Heap is limited . So even if &lt;br&gt;
Javascript offers a effective garbage collection mecanism &lt;br&gt;
automatically, Memory leaks can still occur due to various &lt;br&gt;
reasons like Using Global Variables or Using Too Many Event &lt;br&gt;
Listeners etc etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Call stack&lt;/em&gt;&lt;/strong&gt; -  The Call Stack is nothing but a data &lt;br&gt;
structure,which records basically where in the program we are. &lt;br&gt;
As JavaScript is a single-threaded programming language, it &lt;br&gt;
has only one Call Stack .&lt;/p&gt;

&lt;p&gt;Which means whenever we execute a function i.e we put it on &lt;br&gt;
the top of the stack or when we return from a  function i.e we &lt;br&gt;
pop it off from the top of stack , all of it happens one at a &lt;br&gt;
time.  &lt;/p&gt;

&lt;p&gt;Call stack size is also limited like Memory Heap . So whenever &lt;br&gt;
a program attempts to use more space than there is available, &lt;br&gt;
Stack Overflow occurs .&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why does Javascript choose to be single threaded ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because it is easy and less complicated than multi-threaded environment,&lt;br&gt;
where sometimes you have to deal with scenarios like Deadlocks and all .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But isn't it limiting ? What's gonna happen when things are slow ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes  . If we process things like image processing or network request  synchronously, It can be a cause of browser getting stuck or block . &lt;br&gt;
And that's not the only problem you are going to encounter here . Once the browser starts to process all the remaining tasks, It may stop being responsive for a quite long time .&lt;/p&gt;

&lt;p&gt;I think all of you must remeber this page unresponsive error .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iRSGrKvZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606203516618/xHsjwtVP2.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iRSGrKvZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606203516618/xHsjwtVP2.jpeg" alt="008Ah.jpg" width="462" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So How to prevent Blocking then ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well , the answer is Asynchronous Callbacks . &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wait , you just said it is a single threaded langunage,then how does it handle Asynchronous Callbacks ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well it turns out I have been telling you partial truth this whole time . There's more to the browser than just the engine . It also consist of Event Loop and Call back Queue along with various Web APIs like the DOM,&lt;br&gt;
AJAX (XMLHttpRequest), setTImeout() and many more .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vj6sS1jU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606156278119/5WbWZ-OqY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vj6sS1jU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606156278119/5WbWZ-OqY.png" alt="jre.png" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, you are saying setTimeout() is not a part of javascript then ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes , Technically it's not a part of javascript engine . As it provided by the &lt;br&gt;
Web APIs .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can you give us a example ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sure , Consider the following the codes..&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('1');
setTimeout(()=&amp;gt;{
   console.log('2');
},5000);
console.log('3');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you all know, the output gonna be like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
3
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but do you know how does it arrive at this output ...let me walk you through this ..step by step..&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8B-PVmIR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606147756379/zRQGl31Pc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8B-PVmIR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606147756379/zRQGl31Pc.png" alt="first.png" width="800" height="565"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tQU37jCR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606211663415/ZhNd-Qdtd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tQU37jCR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606211663415/ZhNd-Qdtd.png" alt="second.png" width="800" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YcwKPskn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606151361063/u4_F9tKCV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YcwKPskn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606151361063/u4_F9tKCV.png" alt="third.png" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yo26Hgzd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606151766177/GdphLKa9m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yo26Hgzd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606151766177/GdphLKa9m.png" alt="fourth.png" width="800" height="565"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Five seconds later...&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a0Fb4tnH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606152972947/t4dKqwYKw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a0Fb4tnH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606152972947/t4dKqwYKw.png" alt="fifth.png" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--njfzjEr9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606153741266/ZZ0uGi76V.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--njfzjEr9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606153741266/ZZ0uGi76V.png" alt="sixth.png" width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dUghcWtx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606154222386/M12XGipso.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dUghcWtx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1606154222386/M12XGipso.png" alt="seventh.png" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I have a doubt , What if the setTimeout() is set to 0 ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The result is still going to be same , As the callback by any means not  going to pass through the Event Loop untill the stack is complete empty .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ok,.this looks interesting , Where can I find out about this more  ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have choose to not going into too much depth about it because if you are only starting out it might be overwhelming for you already . But for those who are into the game a little bit longer, I believe the following resources can help them for sure .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/better-programming/how-javascript-works-1706b9b66c4d"&gt;https://medium.com/better-programming/how-javascript-works-1706b9b66c4d&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.bitsrc.io/how-does-javascript-really-work-part-1-7681dd54a36d"&gt;https://blog.bitsrc.io/how-does-javascript-really-work-part-1-7681dd54a36d&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=8aGhZQkoFbQ&amp;amp;feature=emb_title"&gt;https://www.youtube.com/watch?v=8aGhZQkoFbQ&amp;amp;feature=emb_title&lt;/a&gt;&lt;/p&gt;

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