<?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: Vijay Kumar</title>
    <description>The latest articles on Forem by Vijay Kumar (@vijaykumarktg18).</description>
    <link>https://forem.com/vijaykumarktg18</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%2F303185%2Faf840728-fd21-43bf-8763-eb6c55ab8508.jpg</url>
      <title>Forem: Vijay Kumar</title>
      <link>https://forem.com/vijaykumarktg18</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/vijaykumarktg18"/>
    <language>en</language>
    <item>
      <title>Let's Explore Some Fundamental Concepts of Functional Programming</title>
      <dc:creator>Vijay Kumar</dc:creator>
      <pubDate>Tue, 16 Jun 2020 03:52:19 +0000</pubDate>
      <link>https://forem.com/vijaykumarktg18/let-s-explore-some-pieces-of-functinal-programming-493a</link>
      <guid>https://forem.com/vijaykumarktg18/let-s-explore-some-pieces-of-functinal-programming-493a</guid>
      <description>&lt;p&gt;Functional programming, it sounds like something very high and complex concept, right? Don't worry, after reading this blog, you will understand the basic of functional programming(FP).&lt;/p&gt;

&lt;p&gt;So let's start by outlining the topics we are going to learn about.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is abstraction?&lt;/li&gt;
&lt;li&gt;What is functional programming?&lt;/li&gt;
&lt;li&gt;What are the higher-order functions?&lt;/li&gt;
&lt;li&gt;Currying &amp;amp; chaining functions&lt;/li&gt;
&lt;li&gt;Some useful higher-order functions in JavaScript&lt;/li&gt;
&lt;li&gt;Let's summarize the above concepts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I think most of you guys are excited about learning what is FP? It's time to start now.&lt;/p&gt;

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

&lt;p&gt;In everyday life, most of us don't pay attention to the devices we use for our daily purpose. I mean that we don't know how they work internally, do we? In the case of students and learners who are studying those devices or such things as we are learning about programming and JS. The normal people don't consider how their smartphones working and they don't need to consider either. Of course, the smartphone manufacturers hide those internal technical details from their target users. This is the definition of abstraction in a user-friendly way or in abstraction way for the normal people to understand. If we define it literally or in more CS manner, it means that when we work on apps or websites which are based on a large amount of data, we mostly focus on the detail and most important set of data from that large one. We don't need to focus on the data which are not related to our projects. We can see abstraction almost everywhere in real life.&lt;/p&gt;

&lt;p&gt;If we go for admission to a school, college or any kind of academia, they will ask for your full name, your age, gender, grades and parents details like these. But they won't ask the colour you like most, your most favourite places, your favourite foods and your favourite Netflix shows I guess. They are working on a general and standard student model or student class for their particular school or university. And we as developers we have to know the abstraction which has a similar meaning in Computer Science. If you have got bored with text, let's review some code examples.&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;Student&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;gender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;grade&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;gender&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gender&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;grade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subjects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="cm"&gt;/**
* This is a Student constructor which accept five arguments as 
* properties for a student for a particular school or academia.
* This constructor should also access parental details but
* as an example, I'm not going far more details. But when we develop
* a program for students we might need to add those details further.
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  What is functional programming?
&lt;/h1&gt;

&lt;p&gt;How do you understand a function? If we think it mathematically like f(x) = y, it means that x is a variable and when we pass that x to function f, the result will be y. Whatever, it is a little bit daunting if we consider a function mathematically with all the staffs like domain, codomain, range and all. But if we think of Computer Science, it is a little bit similar. For example,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myFavGames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;`Pottery`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Car Racing`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Loop`&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;favGame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gameList&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="s2"&gt;`Your favourite  games list is here`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;gameList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
     &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gameList&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
   &lt;span class="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="s2"&gt;`Enjoy playing them`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;favGame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;favGame&lt;/code&gt; is a function which accepts &lt;code&gt;gameList&lt;/code&gt; as a parameter and obviously &lt;code&gt;gameList&lt;/code&gt; is a variable. Then the result or output from the function is just a bunch of sentences. This is just a normal function.&lt;/p&gt;

&lt;p&gt;Then what is functional programming and is it different from the above functions. It is a programming paradigm like object-oriented programming and procedural programming. But we are going to focus on functional programming which is abbreviated as FP. There are some rules of thumb you have to follow.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Immutability&lt;/li&gt;
&lt;li&gt;Statelessness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A pure function is a function which returns the same output every time you provide it with the same input. And it has to be immutable and stateless. It will be easy to understand with practical.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myFavGames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;`Pottery`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Car Racing`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Loop`&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// Add a new element to the gameList array&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;addGame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gameList&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;newGame&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;newArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;gameList&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
   &lt;span class="nx"&gt;newArr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newGame&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;newArr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;addGame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Plants VS Zombies&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Remove an element from the gameList array&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;removeGame&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;removeGame&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code box, we can see two functions called &lt;code&gt;addGame&lt;/code&gt; and &lt;code&gt;removeGame&lt;/code&gt;. The &lt;code&gt;addGame&lt;/code&gt; function is pure. If we put &lt;code&gt;myFavGames&lt;/code&gt; and &lt;code&gt;Plants VS Zombies&lt;/code&gt; as two arguments, it will return a new array which must be &lt;code&gt;['Pottery','Car Racing','Loop','Plants VS Zombies']&lt;/code&gt;. If we see the second function which is &lt;code&gt;removeGame&lt;/code&gt;, it depends on the outer variable &lt;code&gt;gameList&lt;/code&gt;. It does not accept it as a parameter. It also removes a game name from the &lt;code&gt;gameList&lt;/code&gt; array that will mutate that variable. So we can say that &lt;code&gt;removeGame&lt;/code&gt; isn't a pure function because it causes side-effect. But can we say that &lt;code&gt;addGame&lt;/code&gt; is a pure function because it must return the same output if we provide it with the same input as many time as we want? Then, what about immutability? That function also has to be immutable to become a pure function. The &lt;code&gt;addGame&lt;/code&gt; function accepts &lt;code&gt;myFavGames&lt;/code&gt; as an argument so it is not directly depending on the &lt;code&gt;myFavGames&lt;/code&gt; variable. It also copies the &lt;code&gt;gameList&lt;/code&gt; array and creates a new array. Then do data processing on that new array instead of on the gameList. That means there is no side-effect by using the &lt;code&gt;addGame&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;addGame&lt;/code&gt; doesn't depend on any outer variable. This means it is stateless. If that function depends on any variable directly then it has dependent state. So we can say that our &lt;code&gt;addGame&lt;/code&gt; function is pure. Functional programming is all about using pure functions and working with first-class functions and higher-order functions. There is a list of pure functions provided by JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myFavGames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;`Pottery`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Car Racing`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Loop`&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;myFavGames&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Angry Birds`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// return a new concated array&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;myFavGames&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// return a new sliced array&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;myFavGames&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are also other functions which we gonna talk about later.&lt;/p&gt;

&lt;h1&gt;
  
  
  What are the higher-order functions?
&lt;/h1&gt;

&lt;p&gt;All of the above functions are examples of first-class functions. They simply accept numbers, strings, objects and other data types as arguments. In functional programming, first-class functions are treated as objects. So we can pass functions as arguments and return functions from functions. Higher-order functions use this technique. They accept one or more functions and other data types as arguments and return a function. This makes new possibilities for JavaScript developers. This functionality is also available in languages like Python, Haskell, Scala and they are all based on functional programming including JavaScript.&lt;/p&gt;

&lt;h1&gt;
  
  
  Currying &amp;amp; chaining functions
&lt;/h1&gt;

&lt;p&gt;We can use method currying when we need to provide a function with multiple arguments but we can't put all the arguments at the same time. This is possible because of the help of closure. First, let see an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myFavGames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;`Pottery`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Car Racing`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Loop`&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// Add a new element to the gameList array&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;addGame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gameList&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gameName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;gameList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gameName&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;span class="nx"&gt;addGame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Plants VS Zombies&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;addANewGame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;addGame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myFavGames&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;addANewGame&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;newArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;addANewGame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Plants VS Zombies&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newArr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we are defining &lt;code&gt;addGame&lt;/code&gt; using the concept of currying function. We can use a function by passing multiple arguments one-by-one or as many as you want. In the above case, &lt;code&gt;addGame&lt;/code&gt; function accepts &lt;code&gt;myFavGames&lt;/code&gt; as a single argument and then return a function. Then the returned function accepts &lt;code&gt;Plants VS Zombies&lt;/code&gt; as its input then return a new favourite games list. Of course, you can use more and more functions inside another function as long as you can handle the complexities of code.&lt;/p&gt;

&lt;p&gt;In the above example, you can see that we can use a currying function with all its arguments at the same statement or we can divide each or group of arguments as we want. So we have the advantage of using the specific part of the function when we need. To do so, we have to make sure the main function ( in the above case &lt;code&gt;addGame&lt;/code&gt; ) is first needed to call with its parameters.&lt;/p&gt;

&lt;p&gt;This is all about currying functions. This magic happens because of closure. So closure happens when a function access variables from its outer scope or parent scope. In the above code, the anonymous function ( the returned function ) can access the &lt;code&gt;gameList&lt;/code&gt; argument from its parent &lt;code&gt;addGame&lt;/code&gt; function. It is taking that variable from the parent function although the parent function is already returned. When a function is returned, it is removed from the execution stack. You can read more about &lt;a href="https://dev.to/vijaykumarktg18/how-does-javascript-engine-work-532b"&gt;the execution stack&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then after this, we are going to chaining two or more functions. Chaining functions is just contacting one function with another function. That means when the first function is executed and the outputted result is go into the second function and being processed and so on and so forth.&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;palindrome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&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;tempReversed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;tempReversed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;palindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mmxxmm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;palindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MOM&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;palindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;radar&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;palindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;wxmdjwy&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;span class="nx"&gt;palindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;umbrella&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;span class="nx"&gt;palindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cat&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;

&lt;span class="c1"&gt;// We can simply do like below&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;string&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 World! This is the Chaining Function here!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newStr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;,,,,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newStr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// "here!,,,,Function,,,,Chaining,,,,the,,,,is,,,,This,,,,World!,,,,Hello"&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;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// "Hello World! This is Chaining Function here!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we chained &lt;code&gt;split()&lt;/code&gt; function to &lt;code&gt;temp&lt;/code&gt; string variable using &lt;code&gt;.&lt;/code&gt; operator. The dot operator is usually used as a chaining operator. Then, &lt;code&gt;reverse()&lt;/code&gt; function is chained behind &lt;code&gt;split()&lt;/code&gt; and then it is chained itself by &lt;code&gt;join()&lt;/code&gt; function. In the end, the result is a new string without any side-effects. So all of the three functions are pure functions. This is a basic example of chaining functions.&lt;/p&gt;

&lt;h1&gt;
  
  
  Some useful higher-order functions in JavaScript
&lt;/h1&gt;

&lt;p&gt;Let's see some common higher-order functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myFavGames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;`Pottery`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Car Racing`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Loop`&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// map()&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newGameList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;myFavGames&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;e&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;!!!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newGameList&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;myFavGames&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// filter()&lt;/span&gt;
&lt;span class="nx"&gt;newGameList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Loop&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newGameList&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;myFavGames&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// reduce()&lt;/span&gt;
&lt;span class="nx"&gt;newGameList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;newGameList&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;myFavGames&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// forEach()&lt;/span&gt;
&lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;e&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;myFavGames&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These methods can be applied not only to string arrays but also to any type of arrays and other data types like string and objects. All of the above functions are all pure functions and they are all part of functional programming provide JavaScript. Firstly, &lt;code&gt;map()&lt;/code&gt; function just go through each element of the array and perform any processing on that element. Like this, the &lt;code&gt;filter()&lt;/code&gt; function filters the specific elements based on the provided callback function.&lt;/p&gt;

&lt;p&gt;Likewise, the &lt;code&gt;reduce()&lt;/code&gt; function accumulates all of the elements of the array to a single value which we can assign to a variable. The first argument of the callback function is generally called &lt;code&gt;accumulator&lt;/code&gt; but you can name it as the way you want. After the first argument, the second is each element of the array. After that parameter, we can continue with another optional parameter called the index of each array's element.&lt;/p&gt;

&lt;p&gt;The last but not least is the &lt;code&gt;forEach()&lt;/code&gt; function which simply loops through each element of the provided array. The first parameter represents each element of the array and the second one represent the index of the corresponding array's element. This pattern of parameter list is same as the &lt;code&gt;map()&lt;/code&gt; function and the &lt;code&gt;filter()&lt;/code&gt; function. These four functions are some of the most encountered functions throughout the functional programming in JavaScript.&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's summarize the above concepts
&lt;/h1&gt;

&lt;p&gt;First of all, the above concepts are interconnected to each other and these are just some parts of FP. Functional programming is all about working with functions. The higher-order functions make them a lot easier by providing abstraction and reducing code complexities. They enable us to write simpler code and easier to solve some sorts of problems. Most of JS developers use closures to provide modular programming i.e. we can make functions more securable and private using closures. Here is an instance of Modular Design Pattern.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&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;myFavGames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;`Pottery`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Car Racing`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;`Loop`&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Add a new element to the gameList array&lt;/span&gt;
     &lt;span class="na"&gt;addGame&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newGame&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newGame&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="c1"&gt;// Remove an element from the gameList array&lt;/span&gt;
    &lt;span class="na"&gt;removeGame&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nx"&gt;myFavGames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

   &lt;span class="c1"&gt;// Show game array list&lt;/span&gt;
   &lt;span class="na"&gt;displayList&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&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;myFavGames&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;span class="p"&gt;})();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how we can create private method. &lt;code&gt;game&lt;/code&gt; is an object and it has three methods. We can't access &lt;code&gt;myFavGames&lt;/code&gt; array because it is no more in the execution stack. The private function is returned an object and the game has only access to that object. We can use chaining to simplify codes and to write less code.&lt;/p&gt;

&lt;p&gt;I hope now you get some basic insights into functional programming and how important it is. It is really helpful and makes coding more enjoyable. If you think I don't put the &lt;code&gt;A Quote&lt;/code&gt; section, please let me know your opinion. We can discuss more functional programming via the comments. Have a great day guys!!!🥳🤩😉&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>computerscience</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Asynchronous JavaScript In Details</title>
      <dc:creator>Vijay Kumar</dc:creator>
      <pubDate>Thu, 30 Apr 2020 04:08:33 +0000</pubDate>
      <link>https://forem.com/vijaykumarktg18/asynchronous-javascript-in-details-ng9</link>
      <guid>https://forem.com/vijaykumarktg18/asynchronous-javascript-in-details-ng9</guid>
      <description>&lt;p&gt;So let's see what is asynchronous JavaScript or generally asynchronous programming. Before we dive into the concept, we shall list the topics we gonna think about.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Thread&lt;/li&gt;
&lt;li&gt;Synchronous&lt;/li&gt;
&lt;li&gt;Asynchronous&lt;/li&gt;
&lt;li&gt;Traditional Methods&lt;/li&gt;
&lt;li&gt;Promises&lt;/li&gt;
&lt;li&gt;Async/Await&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the list and we gonna deep dive into one of the above-listed items. Let's start with the first one.&lt;/p&gt;




&lt;h1&gt;
  
  
  1.Thread
&lt;/h1&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%2Fimages.unsplash.com%2Fphoto-1546957236-5fde4e0b25eb%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1502%26q%3D80" 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%2Fimages.unsplash.com%2Fphoto-1546957236-5fde4e0b25eb%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1502%26q%3D80" alt="thread with a needle"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a thread?
&lt;/h2&gt;

&lt;p&gt;A thread is a process or part of a process. When there was the use of multiprocessor becoming popular and people needed more fast computers, then they try to develop a technique called threading a process or multithreading. Then what does the first sentence mean, right? Simply we can define a process as a heavyweight task or job where a thread is a subpart of a process and sometimes refers to as a lightweight process.&lt;/p&gt;




&lt;h2&gt;
  
  
  Single-Threaded
&lt;/h2&gt;

&lt;p&gt;If there is only a single thread for a particular process then that process itself is a thread (called single-threaded) and this process will be running on a uniprocessor system (like a single needle with a thread). A uniprocessor system is a system which has only one single processor (CPU or central processing unit). That's mean every process contains at least one thread which is the process itself. JavaScript itself is an example of a single-threaded system.&lt;/p&gt;




&lt;h2&gt;
  
  
  Multi-Threaded
&lt;/h2&gt;

&lt;p&gt;If there is a single-thread system then there should be its partner, a multi-threaded system. On a multi-threaded system, many threads run subsequently each on its own processor, then that computer system might be a multiprocessor system.  It is like multiple threads in the hole of a needle. If a process is divided into multiple sub-tasks, then each of those sub-tasks is referred to as a thread. Java Virtual Machine (JVM) is an example of a multi-threaded system and most of the today computers are multi-threaded. &lt;/p&gt;

&lt;p&gt;Since JS has only one thread, the main thread, the need for some kind of mechanism becomes vital to meet modern use cases. The concept of asynchronous programming in JS became popular using another thread called worker thread. But both thread can't work together since JS is single-threaded. I'll explain it in more detail.&lt;/p&gt;




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

&lt;p&gt;Synchronous programming is what we do mostly. Most of the code we write work synchronously. let's see the following code example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vijay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Synchronous&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kumar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lastName&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How the above code will process? Firstly, the "Vijay" string will be assigned to the &lt;code&gt;firstName&lt;/code&gt; variable and then it will be consoled. After that, the alert will be popped and at the same time open your browser developer tool to see that whether the line below the alert is processed or not until pressing the &lt;code&gt;OK&lt;/code&gt; button of the alert box. The &lt;code&gt;lastName&lt;/code&gt; variable will be declared and assigned with the string "Kumar" after the alert has been processed. Then the last two consoles will work. This step-by-step approach is called synchronous programming. This is mostly done in almost every programming languages. The main concept is one process or thread at a time.&lt;/p&gt;




&lt;h1&gt;
  
  
  3.Asynchronous
&lt;/h1&gt;

&lt;p&gt;Where the asynchronous programming, two or more threads can be processed at the same if supported by the system. In the case of JS, there was an only the main thread but later there become a worker thread. The worker thread and main thread work independently of each other. The worker thread is also synchronous. That means the worker thread waits for some events to occur and does other remaining processing. By some events, I mean the event like fetching data like JSON or images and many other kinds of data from a server or a remote computer system.&lt;/p&gt;




&lt;h1&gt;
  
  
  4.Traditional Methods
&lt;/h1&gt;

&lt;p&gt;The traditional methods were mostly used before the release of promises and other modern techniques. They are still being used today. So, what are these traditional methods? There are three methods we are going to talk about.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;setTimeout()&lt;/li&gt;
&lt;li&gt;setInterval()&lt;/li&gt;
&lt;li&gt;requestAnimationFrame()&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  setTimeout()
&lt;/h2&gt;

&lt;p&gt;All of the mentioned three methods are used in asynchronous programming. The first one is &lt;code&gt;setTimeout(callback,timeInterval)&lt;/code&gt;. This method accepts two arguments which are not avoidable. You can also add zero or more arguments behind the first two arguments. The first argument is a callback function. A callback function is a function expression that is passed as an argument in another function (in this case is the &lt;code&gt;setTimeout()&lt;/code&gt;). The second argument is the time in a millisecond to wait before executing the callback function. The callback will be called after the specified time interval in a millisecond. We can add extra arguments after the second arguments. The new arguments starting from the third place until the end will be sent to the callback function as parameters to that function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vijay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstName&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;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kumar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, the &lt;code&gt;firstName&lt;/code&gt; is declared and assigned with the string &lt;code&gt;Vijay&lt;/code&gt;. Then, the variable is consoled and the &lt;code&gt;lastName&lt;/code&gt; variable is declared and assigned with &lt;code&gt;Kumar&lt;/code&gt;. And then, it will also be consoled. Finally, the console statement in the setTimeout is processed after waiting 5000 milliseconds (5s) only once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vijay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstName&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;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kumar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;lName&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fName&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;lName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code example show that we can pass more than two arguments in the &lt;code&gt;setTimeout()&lt;/code&gt; function. The arguments after the second arguments are passed as the arguments of the callback function.&lt;/p&gt;




&lt;h2&gt;
  
  
  setInterval()
&lt;/h2&gt;

&lt;p&gt;This function is also similar to the &lt;code&gt;setTimeout()&lt;/code&gt; function except for one thing. The &lt;code&gt;setTimeout()&lt;/code&gt; function evaluates its callback function only once after waiting for the specified time in the second argument. Where, the &lt;code&gt;setInterval()&lt;/code&gt; function execute the callback function more than once. Each execution takes place after waiting the time passed as the second argument in the &lt;code&gt;setInterval()&lt;/code&gt; function. Simply timeout function executes its callback only once where interval function processes its callback function until close the browser or tab in which it's running.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vijay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstName&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;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kumar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code block executes the callback as same as the timeout one but &lt;code&gt;setInterval&lt;/code&gt; processes the callback many time.&lt;/p&gt;

&lt;p&gt;There is a way to cancel the execution of the above two set functions (&lt;code&gt;setTimeout&lt;/code&gt; and &lt;code&gt;setInterval&lt;/code&gt;). We can use &lt;code&gt;clearTimeout()&lt;/code&gt; and &lt;code&gt;clearInterval()&lt;/code&gt; to cancel or stop execution of the set functions respectively.&lt;br&gt;
Both set functions return an identifier which we use to clear timeout and interval.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vijay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstName&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;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kumar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lastName&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;identifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;identifier&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;We can use &lt;code&gt;clearInterval&lt;/code&gt; on &lt;code&gt;setTimeout&lt;/code&gt;'s identifier and vice versa, but this is not recommended and this is not a best practice.&lt;/em&gt;&lt;/p&gt;


&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  requestAnimationFrame()
&lt;/h2&gt;

&lt;p&gt;This method is mostly used in game development or animation in a browser or any web environment. This optimizes the web app performance if uses correctly. If we develop an animation, we can use &lt;code&gt;requestAnimationFrame()&lt;/code&gt;. But the smoothness of the animation mainly depends on the unit called &lt;strong&gt;&lt;em&gt;frame per second(FPS)&lt;/em&gt;&lt;/strong&gt;. Maybe you know this unit or maybe not, you have might be seen this unit in video related terminologies and in-game terminologies too.&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;thousandCircles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&gt;// This section contains codes to generate one thousand random circles&lt;/span&gt;
   &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;thousandCircles&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;thousandCircles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the preceding code section, the &lt;code&gt;requestAnimationFrame()&lt;/code&gt; method with parameter as its parent function which is &lt;code&gt;thousandCircles()&lt;/code&gt; function. If we want to use a function then we need to call that function with require parameters passed in.&lt;/p&gt;




&lt;h1&gt;
  
  
  4.Promises
&lt;/h1&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%2Fimages.unsplash.com%2Fphoto-1535578195295-f2329b3cdb8d%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D300%26q%3D400" 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%2Fimages.unsplash.com%2Fphoto-1535578195295-f2329b3cdb8d%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D300%26q%3D400" alt="thread with a needle"&gt;&lt;/a&gt;&lt;br&gt;
Photo by Valentin Antonucci on Unsplash&lt;/p&gt;

&lt;p&gt;A promise is another way of implementing asynchronous programming in JavaScript. Why do we need promise at all after having &lt;code&gt;setTimeout&lt;/code&gt;,&lt;code&gt;setInterval&lt;/code&gt; and &lt;code&gt;requestAnimationFrame&lt;/code&gt;. But using the set methods we can face problems when we need to implement chain asynchronous codes or methods. It is inefficient to use set methods because they use callback functions. Take a look at the following example...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;printBio&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
   &lt;span class="nf"&gt;printFullName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
     &lt;span class="nf"&gt;printAge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bio&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Your name is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; and your age is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. Your full bio is 
                   &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;bio&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;);
     },failCall());
   },failCall());
},failCall());
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code is an example of callback hell. The callback hell is happened when we nest many callback functions inside of others. This may lead to errors and many complications. So to solve the above problem, we have promise in JavaScript. JavaScript mostly used in chaining many asynchronous processes and callback functions. There are four stages in processing a promise.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pending - The promise is waiting for the result means the promise is currently processing.&lt;/li&gt;
&lt;li&gt;Fulfilled - The promise is processed successfully and has returned the result. Sometimes called resolved.&lt;/li&gt;
&lt;li&gt;Rejected - The promise is failed processing and has returned an error.&lt;/li&gt;
&lt;li&gt;Settled - The promise is processed but the promise might be resolved or rejected.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's see a code example for a promise.&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="nf"&gt;printBio&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;printFullName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;printAge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bio&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Your name is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; and your age is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. Your full bio is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;bio&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;));
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The printBio function will be resolved or rejected, but we don't know when it will resolved or rejected. We can't even guarantee that whether the printBio function will be resolved or rejected. The above code processes only one promise at a time. U can implement multiple promises at the same time.First let's see another example of full promise code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;rej&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;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&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;x&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nf"&gt;res&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;rej&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;span class="nx"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="c1"&gt;// do something)&lt;/span&gt;
       &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="c1"&gt;// do something)&lt;/span&gt;
       &lt;span class="p"&gt;...&lt;/span&gt;
       &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="c1"&gt;// do error handling);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, first we create a new promise object and then pass a callback function with &lt;code&gt;res&lt;/code&gt; and &lt;code&gt;rej&lt;/code&gt; arguments. Then we do some processing in the callback function. After creating the object, we can attach as many &lt;code&gt;then&lt;/code&gt; as we want for more data processing sequentially. The first &lt;code&gt;then&lt;/code&gt; will be process when only the promise is resolved. Then another &lt;code&gt;then&lt;/code&gt; will be processing. There can be attached any numbers of &lt;code&gt;then&lt;/code&gt; into a promise(...). If some error is returned from the promise object, the &lt;code&gt;catch&lt;/code&gt; part of the code will be processed. There is another code for the multiple promises.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="c1"&gt;// do processing)&lt;/span&gt;
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="c1"&gt;// do processing)&lt;/span&gt;
                    &lt;span class="p"&gt;...&lt;/span&gt;
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="c1"&gt;// do error handling);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code will also be processed with the same manner as the single promise.   The &lt;code&gt;a,b,c&lt;/code&gt; in the array represents individual promise and &lt;code&gt;then&lt;/code&gt; part of the code will only be processed when all of the given promises in the array are resolved. If any of the given promises is rejected, the whole promise block will be rejected and the &lt;code&gt;catch&lt;/code&gt; part will be executed.&lt;/p&gt;

&lt;h1&gt;
  
  
  5.Async/Await
&lt;/h1&gt;

&lt;p&gt;Async/Await is another new method to implement asynchronicity in javascript. As I said, this is relatively a new technique. What we actually do in this technique is we declare an async function and use await inside that function to perform the function asynchronously. So let's see what is async. &lt;code&gt;async&lt;/code&gt; is a keyword which can be abbreviated as asynchronous, but we can only use &lt;code&gt;async&lt;/code&gt; keyword in JS code not the asynchronous. We put it at the beginning of a function signature. The people who don't know what function signature actually is the line in the function declaration ( in case of javascript, that line is &lt;code&gt;function funcName(parameters list...)&lt;/code&gt;). The keyword &lt;code&gt;function&lt;/code&gt; and the function name and parentheses with parameters. So when we put async in front of a function, it will become &lt;code&gt;async function funcName(parameters list...)&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="c1"&gt;// Normal function&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calAge1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2020&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;calAge1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// this will return the function declaration or expression&lt;/span&gt;
&lt;span class="nf"&gt;calAge1&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// this will return your age&lt;/span&gt;

&lt;span class="c1"&gt;// Async function&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calAge2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2020&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;calAge2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// this will return the function declaration with async keyword !!! Notice&lt;/span&gt;
&lt;span class="nf"&gt;calAge2&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// this will return a promise&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you call any of the above function, the first one will return a number and the second one will return a promise. If you want to check, just open your browser developer console and try implementing the above code. After all, it is a great tool to learn JS. You might be thinking about how to use the return promise, then we can use the return promise by appending the &lt;code&gt;then&lt;/code&gt; keyword. Let see below...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Async function&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calAge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2020&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;calAge&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// this will return the function declaration with async keyword !!! Notice&lt;/span&gt;
&lt;span class="nf"&gt;calAge&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// this will directly alert your calculated age.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What is await? It is a JS feature we can only use inside an async function. First, see the code below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Async function&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calAge2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;birthYear&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;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2020&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;calAge2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// this will return the function declaration with async keyword !!! Notice&lt;/span&gt;
&lt;span class="nf"&gt;calAge2&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;then&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="c1"&gt;// this will return a promise&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function will also return a promise but only once the promise is either resolve or reject due to the use of &lt;code&gt;await&lt;/code&gt;. The await will wait for the promise to resolve. Then the promise will be returned and logged into the console since we use &lt;code&gt;then&lt;/code&gt; on the returning promise. Instead of calculating age, we can do many things with await. Mostly, fetching data from the server using &lt;code&gt;fetch&lt;/code&gt; and all. If you wanna learn more, then Mozilla Developer Network is a great resource, try it.&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous" rel="noopener noreferrer"&gt;=&amp;gt; Asynchronous JavaScript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the end of this article and I hope this will help the readers. During this lockdown, we can learn new things and try our concepts and theory in practice. You can learn new things and teaches them through articles, blogs and videos. Please stay home, stay safe, stay learn, do practice.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How does JavaScript engine work?</title>
      <dc:creator>Vijay Kumar</dc:creator>
      <pubDate>Fri, 27 Mar 2020 15:14:20 +0000</pubDate>
      <link>https://forem.com/vijaykumarktg18/how-does-javascript-engine-work-532b</link>
      <guid>https://forem.com/vijaykumarktg18/how-does-javascript-engine-work-532b</guid>
      <description>&lt;p&gt;Have you ever been heard of execution stack? If your answer is no then you can follow along with this blog and if yes you can just review about execution context and execution stack. How does JS engine work? Let's find out the JS working mechanism together. We will have to find out what are the followings and how they work.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Execution Context&lt;/li&gt;
&lt;li&gt;Execution Stack&lt;/li&gt;
&lt;li&gt;Global Execution Context&lt;/li&gt;
&lt;li&gt;Function Execution Context&lt;/li&gt;
&lt;li&gt;Hoisting&lt;/li&gt;
&lt;li&gt;Eval Execution Context&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, we are going to study all of the above topics in detail. Let's start...&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh2ymbe9rzbj4r6vi39pv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh2ymbe9rzbj4r6vi39pv.png" alt="Execution Context"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  1. Execution Context
&lt;/h1&gt;

&lt;p&gt;Execution context is an environment or surrounding in which a specific type of JavaScript code is executed. Execution of JS codes is changed from context to context. Each execution has some particular properties and they share some similar properties too. There are three types of execution contexts&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Global Execution Context&lt;/li&gt;
&lt;li&gt;Function Execution Context&lt;/li&gt;
&lt;li&gt;Eval Execution Context&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each execution context store as a JavaScript object in the Execution Stack. You can see all of the execution contexts on the above image, in which the outer yellow box represents the global execution context. The pink ones are the function execution context and the light green one inside the &lt;code&gt;test()&lt;/code&gt; function is the eval execution context. Don't worry, we will explore these different contexts later. Just follow me. OK!🦾🐱‍👤&lt;/p&gt;
&lt;h1&gt;
  
  
  2. Execution Stack
&lt;/h1&gt;

&lt;p&gt;As you know, a stack in computer science is like the stack of books, plates or maybe the doughnuts🍩 in the above cover photo. The stack is last-in-first-out (LIFO) i.e. that the book you just &lt;code&gt;push&lt;/code&gt; in the stack will be at the base of the stack and the book you put last in the stack will be easier to take out from the stack then the book at the base of the stack. So this nature is also the same for Computer Science. In execution stack, instead of books, the stack will contain the global context, function contexts and eval contexts. The stack keeps track of the current instruction being executed by the JavaScript engine or any compiler or interpreter. Firstly, the global context store in the stack which comes down to the base of the stack and the remaining function or eval contexts will take place in the stack on each other based on the order of your JS codes. When each function or eval is executed by JS engine, the function or eval context is popped  (&lt;code&gt;pop&lt;/code&gt;) from the stack. &lt;code&gt;push&lt;/code&gt; and &lt;code&gt;pop&lt;/code&gt; are popular commands, in some programming languages, which are used to put or take data from the stack.&lt;/p&gt;

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

&lt;p&gt;As you can see in the above image that any execution stack contain only one global execution context. Which type of codes executed in the global context? Of course, the codes which are not in any functions. When a JavaScript program is run, the global context is the first one which is pushed onto the execution stack.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Vijay`&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;hobby&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`painting`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;hobby&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`My name is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;myName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; and My hobby is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;hobby&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/*
 * Anything outside the functions which represent function execution context are 
 * all inside global execution context.
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  4. Function Execution Context
&lt;/h1&gt;

&lt;p&gt;When a function is executed in a JavaScript program, an object representing the function is pushed onto the execution stack. There are two phases in pushing the function execution context object. They are as follow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creation phase&lt;/li&gt;
&lt;li&gt;Execution phase&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's watch how the above two phases work behind the scene.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creation Phase
&lt;/h2&gt;

&lt;p&gt;In the creation phase, the function execution context object is created. If we further down the execution object, we can divide that into two environments.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lexical Environment&lt;/li&gt;
&lt;li&gt;Variable Environment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without wasting time, let's see what they are.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lexical Environment
&lt;/h3&gt;

&lt;p&gt;The lexical environment is a representation or composition of identifiers (variable's or function's names) and the variables themselves, the reference to the primitive value or objects, in a specific structure. This environment also holds a reference to the parent lexical environment. We are going more deeper. Don't worry, I will summarise the whole article at the end and this gonna be the last detail we are diving in. So we can differentiate the lexical environment into three parts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variable object (VO) or Environment record - a new object is created for the arguments passed to the function and it is called argument object. We can use the argument object when we don't know how many arguments are passed to the function. Then the function is view thoroughly by the JS engine to create a property which points out that function. For each local variable inside the function, a property is created with the &lt;code&gt;undefined&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Please notice this place, we will reference later to this point in the &lt;strong&gt;&lt;em&gt;HOISTING&lt;/em&gt;&lt;/strong&gt; section of this article.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Scoping and Scope Chain - every function declaration creates a scope ( like range or area ). All the arguments passed to the function and the variables declared inside the function are locked in the scope of that function. Global variables are the only variables that can be accessed anywhere in the code. Local variables are variables which are declared inside a functional scope. These local variables cannot be accessed from the global scope or their parent scope. If you want to know more about global and local variables, I will provide links to some articles. If your code tries to access local variables from the global scope, the JS engine will generate an error. When one or more functions are nested inside of another function, this nesting will create a scope chain. For example, if there is a function in which another function is nested. Then the scope chain for the nesting function will look something like this.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Vijay`&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;hobby&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`painting`&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;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Hello`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;hobby&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;birthYear&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;! My name is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;myName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; and My hobby is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;hobby&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/*
 * Anything outside the functions which represent function execution context are 
 * all inside global execution context.
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For function age, its scope chain contains its local scope, its parent function's scope which is &lt;code&gt;display&lt;/code&gt; and the global function scope. If this function has to access a variable in global scope like &lt;code&gt;greet&lt;/code&gt;, then it will find the &lt;code&gt;greet&lt;/code&gt; variable in its local scope. If it didn't find the variable, then it will search one level up in the parent function scope. If it didn't find there too, then it will move to the global scope. This is called the scope chain. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This binding - most novice programmers get confused with &lt;code&gt;this&lt;/code&gt; keywords. Look at the following code statement.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//this.(method or function or property);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Actually when a &lt;code&gt;this.&lt;/code&gt; is found in the code, &lt;code&gt;this&lt;/code&gt; usually refers to an object in which scope it is called. When &lt;code&gt;this&lt;/code&gt; keyword is used inside a function, then &lt;code&gt;this&lt;/code&gt; will indicate to the global window object in the browser. If it is called using any method or property, then it belongs to a specific object in which the method is invoked. The &lt;code&gt;this&lt;/code&gt; keyword is not assigned a value until the function it is in is invoked.&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;class&lt;/span&gt; &lt;span class="nc"&gt;People&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="c1"&gt;// 'this' inside this method is not referencing to any object yet. It will &lt;/span&gt;
    &lt;span class="c1"&gt;// reference to an object when it is invoked.&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`My name is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; and I am &amp;amp;{this.age} years old`&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;vijay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;People&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Vijay&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Here, `this` from the display function reference to the vijay &lt;/span&gt;
&lt;span class="c1"&gt;// object&lt;/span&gt;
&lt;span class="nx"&gt;vijay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getThis&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="c1"&gt;// 'this' in the statement point to the browser's window object which is in &lt;/span&gt;
  &lt;span class="c1"&gt;// global  scope&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="cm"&gt;/*
 * Anything outside the functions which represent function execution context are 
 * all inside global execution context.
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Variable Environment
&lt;/h3&gt;

&lt;p&gt;The variable environment and lexical environment are almost the same. The variable environment also has a variable object(VO), scope, scope chain and &lt;code&gt;this&lt;/code&gt; binding. There is only one difference after ES6. The lexical environment used to store function, &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; where the variable environment is for &lt;code&gt;var&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Execution Phase
&lt;/h2&gt;

&lt;p&gt;During this phase, the codes are executed. The variables are assigned with their appropriate values and the functions do their jobs. Each of the functions pushed on the stack are executed in a first-in-last-serve manner. When a function is executed, its function execution context is removed from the execution stack.&lt;/p&gt;

&lt;h1&gt;
  
  
  5. Hoisting
&lt;/h1&gt;

&lt;p&gt;All javascript developers should know the concept of hoisting. This is a new term born with &lt;a href="http://www.ecma-international.org/ecma-262/6.0/index.html" rel="noopener noreferrer"&gt;ES2015&lt;/a&gt;. The actual concept is that when we declare a variable or a function in JavaScript we can use them before the declaration. Let me explain with some codes. We are going to refer the variable object (VO) section in this blog.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Hoisting with a variable.&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 

&lt;span class="cm"&gt;/* 
 *The console output will be "undefined" because of the hoisting enables the 
 *variable available at the interpreting time.
 */&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Declaration&lt;/span&gt;
&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vijay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Initialization&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Output will be "Vijay"&lt;/span&gt;

&lt;span class="c1"&gt;// Hoisting with function&lt;/span&gt;

&lt;span class="nf"&gt;age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1999&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="cm"&gt;/*
 * In the case of a function, the output will be "21" instead of "undefined" 
 *because the function performed its operation during interpretation.
 */&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;currentYear&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentYear&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;birthYear&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Output will be "20"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As in the above code and the reference from the VO section, we now know that when a variable is declared, it will be assigned with &lt;code&gt;undefined&lt;/code&gt; due to hoisting during the interpretation. When the variable is initialized with a value, then there will be no effect because of hoisting. Where a function declaration enables the program to use the function before its declaration statement in the code. These are all the effect of hoisting. In technical term, during interpretation, the variable declarations take places for those variables on the memory and this is same for function. That's why we can access the variables and functions before their declaration.&lt;/p&gt;

&lt;h1&gt;
  
  
  6. Eval Execution Context
&lt;/h1&gt;

&lt;p&gt;The last but not least is the eval execution context. We are not going to do detail discussions about eval execution context because most programmers do not use this. It is obsolete. That means that it is still supported by browsers but it is a best practice not to use eval in any new project you are going to start. The actual function it does is nothing but only executed string which is just javascript code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Eval execution context&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;eval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`2+2`&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// the console output will be "4"&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;eval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2 + 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nf"&gt;eval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2 + 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt; &lt;span class="c1"&gt;//  the console output will be "false"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the end of our blog. I hope I provided as much knowledge I know about JS and you can read the following articles which will explain in more detail.&lt;/p&gt;

&lt;p&gt;Further reading&lt;br&gt;
&lt;a href="https://tylermcginnis.com/ultimate-guide-to-execution-contexts-hoisting-scopes-and-closures-in-javascript/" rel="noopener noreferrer"&gt;The Ultimate Guide to Hoisting, Scopes, and Closures in JavaScript&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval" rel="noopener noreferrer"&gt;eval() and eval execution context&lt;/a&gt;&lt;br&gt;
&lt;a href="https://blog.bitsrc.io/understanding-execution-context-and-execution-stack-in-javascript-1c9ea8642dd0" rel="noopener noreferrer"&gt;Understanding Execution Context and Execution Stack in Javascript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.pexels.com/@mccutcheon" rel="noopener noreferrer"&gt;Cover Photo by Sharon McCutcheon from Pexels&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What is variable in javaScript?</title>
      <dc:creator>Vijay Kumar</dc:creator>
      <pubDate>Sun, 09 Feb 2020 13:53:49 +0000</pubDate>
      <link>https://forem.com/vijaykumarktg18/what-is-variable-in-javascript-3d95</link>
      <guid>https://forem.com/vijaykumarktg18/what-is-variable-in-javascript-3d95</guid>
      <description>&lt;p&gt;As the title is "What is variable in JavaScript?", we gonna talk about variables in JavaScript. Every high-level programming languages have variables.If we define variable in simple term, a variable is act as a container in which a value or a set of values is stored.But in this blog, we are going to learn about the variable in more detail.As always, I divided this blog into 6 sections.Please read them in order to the get the core concept of variables in JavaScript.This is the list of the sections:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is a variable?&lt;/li&gt;
&lt;li&gt;Statically Typed Language Vs Dynamically Typed Language&lt;/li&gt;
&lt;li&gt;Datatypes&lt;/li&gt;
&lt;li&gt;Declaring variables in JS&lt;/li&gt;
&lt;li&gt;Difference between var and ES6 let, const&lt;/li&gt;
&lt;li&gt;Immutable and Mutable&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So lets dive in....&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What is a variable?
&lt;/h2&gt;

&lt;p&gt;As we defined the variable as a container for certain value or set of values. Actually it acts as the memory address where the value is stored.The value of a variable is always changing. There is something called &lt;code&gt;const&lt;/code&gt; which is used to stored constant which never change after declaring it.We will talk about this later in this blog of course.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Statically Typed Language Vs Dynamically Typed Language
&lt;/h2&gt;

&lt;p&gt;There are two types of programming languages based on variable declaration and one of them is &lt;strong&gt;'statically typed language'&lt;/strong&gt; and the other one is &lt;strong&gt;'dynamically typed language'&lt;/strong&gt; ( also called loosely typed language). Programming languages such as C, C++ and Java are statically typed languages where languages such as Ruby, Python and JavaScript are dynamically typed languages.May be you are thinking of what is statically typed language and dynamically typed language.A statically typed language is a language in which variable can store only one specific type of data (such as integers,decimal numbers, string, and boolean, you will know about them later in this blog). A language which can store any datatype is called a dynamically typed language.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Statically typed language &lt;/span&gt;
&lt;span class="c1"&gt;// Java Syntax&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;n3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;34.5353524342343&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Statically typed language"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; 
&lt;span class="c1"&gt;// Variable n1 can only store integer type and like this n2 can only store float.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Dynamically typed language &lt;/span&gt;
&lt;span class="c1"&gt;// JavaScript Syntax&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;34.334&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Mike&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&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;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dynamically typed language&lt;/span&gt;&lt;span class="dl"&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;flag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Variable n can retain any type of values&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Datatypes
&lt;/h2&gt;

&lt;p&gt;We can generally divided datatypes into two different groups.The first one is primitive datatypes which are number,string,boolean,undefined and null. Array, function, obejct, date and others are all objects.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdsrpzw88ebd55kfsi6lv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdsrpzw88ebd55kfsi6lv.jpg" alt="Different datatypes in JS"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Number
&lt;/h3&gt;

&lt;p&gt;In statically typed languages like Java has many different datatypes(&lt;code&gt;int&lt;/code&gt;, &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;double&lt;/code&gt;, &lt;code&gt;long&lt;/code&gt; and &lt;code&gt;short&lt;/code&gt;) to represent numbers.But in JS, there is only one datatype for numbers and it is &lt;em&gt;number&lt;/em&gt; itself to represent integers and decimal number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Numbers in JS&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;integer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&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;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;34.334&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;double&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;34543.4543545&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  String
&lt;/h3&gt;

&lt;p&gt;As it name, string is a group of characters( in simple words string is just text). This datatype is one of the important because you are going to interact with strings in everyday use apps or websites.You can wrap a string value within single quote('single quote'), double quote("double quote") and the new one, which is part of ES6(ES 2015), is template literal(&lt;code&gt;template literal&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="c1"&gt;// Strings in JS&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;doubleQ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;double quote&lt;/span&gt;&lt;span class="dl"&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;singleQ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;single quote&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tempLit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`template literal`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Boolean
&lt;/h3&gt;

&lt;p&gt;Boolean has only two values, &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt;. Boolean is mostly used in conditional statements where we check for some conditions which may return either &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;. You will encounter with boolean in many programming. There are some beginners who put boolean values in quote like string which is wrong. Boolean values do not require any quote or template literal. We can also check boolean values for expressions. We can sometime call &lt;em&gt;truthy&lt;/em&gt; the value which are true and &lt;em&gt;falsy&lt;/em&gt; for the false value. All values are truthy except the only falsy values which are &lt;code&gt;false&lt;/code&gt;,&lt;code&gt;0&lt;/code&gt;,&lt;code&gt;NaN&lt;/code&gt;,&lt;code&gt;0n&lt;/code&gt;,&lt;code&gt;null&lt;/code&gt; and &lt;code&gt;undefined&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="c1"&gt;// Boolean in JS&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;truthy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&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;falsy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&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="mi"&gt;5&lt;/span&gt;&lt;span class="o"&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;// this expression will be true.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// this expression will be false.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Undefined and Null
&lt;/h3&gt;

&lt;p&gt;Sometime people think undefined and null are similar where undefined is undefined datatype and null is an object. If a new variable is declared without any data assignment then it is &lt;code&gt;undefined&lt;/code&gt;. We can assign &lt;code&gt;null&lt;/code&gt; as a value for a particular 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="c1"&gt;// Undefined and Null in JS&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Now the variable 'integer' contains undefined&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;34.334&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Now the variable 'float' contains null&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Object
&lt;/h3&gt;

&lt;p&gt;JavaScript has special datatype called &lt;em&gt;object&lt;/em&gt;. If we define object in simple term then an object is just a set of (key:value) pairs. Most of the functionalities supported by JS are objects. All of the above datatypes are fundamental datatypes that means that they are unavoidable in JS. In value from the key-value pair of an object can be any of the above datatype including object itself. As we know that null is an object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Objects in JS&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;briefBio&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;45&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;married&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Full Stack Web Developer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="c1"&gt;// This is a simple object&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// This is an array&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;yearOfBirth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;currentYear&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt; &lt;span class="c1"&gt;// This is a function&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentYear&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;yearOfBirth&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Declaring variables in JS
&lt;/h2&gt;

&lt;p&gt;We have some constraints in declaring variables. Every developer should follow these constraints which is part of best practices. Best practices allow developers to write clean code, easier to debug and collaborate on a project and persist consistencies in codes of different programmers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variable name should always start with letter or $ , we can't use anything else for the start of variable name.&lt;/li&gt;
&lt;li&gt;Variable name should be meaningful which is best practice. You can give a variable name which is not associated with the value going to in it. This will later may create difficulties for you and any other programmer who get your project.&lt;/li&gt;
&lt;li&gt;Variable should be one word. We cannot use spaces in variable name but if your variable name have more than one word you can use underscore(_) instead of space to separate the words. Your variable name should not be greater than 2 or 3 words.You can also use camel casing where the starting letter of the variable name will be small and the starting letter of the remaining words in the variable will be capitalized(&lt;code&gt;var favoriteColor = 'light green';&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;You cannot use JavaScript keywords(&lt;code&gt;let&lt;/code&gt;,&lt;code&gt;class&lt;/code&gt;,&lt;code&gt;function&lt;/code&gt;,&lt;code&gt;true&lt;/code&gt;,etc.) as variables' name. There are some reserved words in JS which are also not available for variable name declaration.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9bazwiwqkyjx2ya1292j.png" alt="JavaScript Keywords and Future Reserved Words"&gt;
&lt;a href="https://www.ecma-international.org/ecma-262/5.1/#sec-A.1" rel="noopener noreferrer"&gt;Photo from ECMAScript International&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Variable declaration in JS&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;$favoriteFood&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light foods&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// variable name starting with $&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lucky_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;93&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// variable name using underscore&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;briefBio&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// Camel Case&lt;/span&gt;
   &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;45&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;married&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Full Stack Web Developer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Difference between var and ES6 let, const
&lt;/h2&gt;

&lt;p&gt;The keyword &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are arrived in JS in 2015 when ECMAScript announced it ES6(ES 2015). Before that time most developers used &lt;code&gt;var&lt;/code&gt; to declare variables. There are also some people who still use &lt;code&gt;var&lt;/code&gt; today. The main difference between &lt;code&gt;var&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; is that when we declare a variable using &lt;code&gt;var&lt;/code&gt; keyword, we can declare a variable with the same name as much as we want. This make inconsistencies in code which may become error prone. Using &lt;code&gt;var&lt;/code&gt; keyword we can declare as much variables with the same name as we want. Where the &lt;code&gt;let&lt;/code&gt; keyword does not allow this fault. We can declare only a variable with a particular name only once with &lt;code&gt;let&lt;/code&gt; keyword. If you try to declare a variable with the name which has already been taken by some other variable, browser's JS engine will generate error on the console. The remaining &lt;code&gt;const&lt;/code&gt; keyword is same as the &lt;code&gt;let&lt;/code&gt; keyword except that the value of the variable which is declared using &lt;code&gt;const&lt;/code&gt; cannot be changed once declared. Where the value of the variable declared using &lt;code&gt;let&lt;/code&gt; keyword can be changed by assigning the value to the 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="c1"&gt;// Difference between var and ES6 let, const in JS&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;$favoriteFood&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light foods&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;$favoriteFood&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;45&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// This is allowed with var keyword&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lucky_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;93&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;lucky_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Junk food&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// This will generate error &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Immutable and Mutable Datatype
&lt;/h2&gt;

&lt;p&gt;What are immutable and mutable datatypes? Immutable means that we cannot change the value of a variable explicitly i.e. if we want to change the value of a variable, then we can assign the new value using the assignment operator(=). Mutable means the value of a variable can be changed explicitly.Lets see the code below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Mutable&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Miracle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;23&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;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;89&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;83&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Mike&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/* 
After executing the above statements the person object will be something like below
The new value of person object
person = {
  name: 'Mike',
  age: 23
}
The new value of array
arr = [34,55,89,83,23];

In immutable we don't need to assign the whole object to change one single value like the below
person = {
  name: 'Mike',
  age: 23
}
*/&lt;/span&gt;

&lt;span class="c1"&gt;//Immutable&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;teacher&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Developer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;retirement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;retirement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;66&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/* 
After executing the above statements the job variable will be something like below
The new value of job variable
job = 'Developer';
The new value of retirement variable
retirement = 66;
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we are now at the end of this blog and I hope all of you guys learned some new things about variables in JavaScript and enjoyed this post. Please let me know my needs in writing blogs if you found during this blog via comments. Thank you for reading through out the end. Have a great day!:);)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.pexels.com/@pixabay" rel="noopener noreferrer"&gt;Cover Photo by Pixabay from Pexels&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>2020, Start of a new tech journey</title>
      <dc:creator>Vijay Kumar</dc:creator>
      <pubDate>Fri, 17 Jan 2020 13:47:30 +0000</pubDate>
      <link>https://forem.com/vijaykumarktg18/2020-start-of-a-new-tech-journey-40df</link>
      <guid>https://forem.com/vijaykumarktg18/2020-start-of-a-new-tech-journey-40df</guid>
      <description>&lt;p&gt;More than half of the first month of 2020 has been passed and may be everyone have already started to learn new things, new startups, new careers and many new things. May be there will be some people thinking of studying new technology skills. But don't know how to start and from where to start. I wrote this blog for those who has been confused between competing tech skills.I hope this blog will help them.&lt;/p&gt;

&lt;p&gt;There are many tech skills or fields and among them only some will become major players in 2020. After all, computer fields are always evolving. But to become a successful goal keeper, people also need to maintain some soft skills (such as time managements and habits), we talk about them later in this blog.&lt;/p&gt;

&lt;p&gt;I divided this blog into three parts and they are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Programming Languages&lt;/li&gt;
&lt;li&gt;Tech Skills/ Fields&lt;/li&gt;
&lt;li&gt;Soft Skills&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, lets start...&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvx9yp6xcdjxrvg5j9t3e.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvx9yp6xcdjxrvg5j9t3e.jpeg" alt="Programming Languages"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hackernoon.com/top-3-programming-language-to-watch-out-in-2019-95995e81ad2b" rel="noopener noreferrer"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Programming Languages
&lt;/h1&gt;

&lt;p&gt;The languages in the list are not ordered by any constraints or on any basis.They are just unordered.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Python
&lt;/h2&gt;

&lt;p&gt;The language which is famous for research, complex computations, machine learning and many other famous fields. It can be used for back end in web development with django framework. It is also easy to language for beginner. But today, python is famous for artificial intelligence and machine learning.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Kotlin
&lt;/h2&gt;

&lt;p&gt;Kotlin is mostly used for android app developments after Google introduced Kotlin as an official language for android app development along with Java and C++ at its annual I/O in 2017. Before this language Java used to be language for android development.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Java
&lt;/h2&gt;

&lt;p&gt;Although kotlin is used as android app development, there are some android app developed with java. Java is mostly famous for enterprise software. Web developer can use java as a back end language for web apps but java is not suitable for web development.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  JavaScript and Node.JS
&lt;/h2&gt;

&lt;p&gt;The language, which totally changes the old static web pages with modern dynamic web apps and lot of new features added to web app developments. Node.JS is used in back end development.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  TypeScript
&lt;/h2&gt;

&lt;p&gt;TypeScript is developed by Microsoft and it is superset language of JavaScript. The TypeScript codes are compiled into plain JavaScript. The language is eventually becoming popular among web developers.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Go Lang
&lt;/h2&gt;

&lt;p&gt;This language origin is Google and it is mostly based on C/C++. The language is fast and have increasing trend in enterprise software development and AI too.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Swift
&lt;/h2&gt;

&lt;p&gt;Apple developed swift for its app developments. Before swift, Objective C was used for IOS apps. As always, changes occur everywhere, apple changed objective C with swift. This language also have rising trends.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  C/C++
&lt;/h2&gt;

&lt;p&gt;C, the mother of programming languages, is used for many purpose from compiler developments to writing code for low level hardware and also in game development.They are the base of the most modern high level programming languages. Both languages are mostly closer to the machine then any other high level language and their speed is a matter which also make the languages survive after born in 1972.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  R programming Language
&lt;/h2&gt;

&lt;p&gt;The language is best for statistical computing and graphics. It is mostly used in statistic programs and in data mining related problems.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  C Sharp
&lt;/h2&gt;

&lt;p&gt;As we know, windows OS is one of the most popular operating system and we can use C# to develop software for windows OS and can also use for game development with unity.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ff48w9vr3112n3a8duvs8.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ff48w9vr3112n3a8duvs8.png" alt="Computer Fields"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Tech Skills/ Fields
&lt;/h1&gt;

&lt;p&gt;The fields order is random.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Artificial Intelligence ( AI )
&lt;/h2&gt;

&lt;p&gt;I hope some of you guys have heard of AI. It is currently the most popular tech field. As it is called artificial intelligence, this technology adds virtual intelligence to modern devices and software. It is also help in almost all the field. AI is transforming the world more rapidly then any other technology. Machine learning and deep learning are parts of AI, which are also becoming popular.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Internet of Things ( IoT )
&lt;/h2&gt;

&lt;p&gt;As the world is becoming more and more innovative, there are new technologies helping human to make a better world. IoT is changing the traditional electronic devices. This technology is making those devices to work in an interconnected structure. IoT is becoming the foundation for the future smart cities. The IoT will become more powerful with AI, and there are some trends heading to AIoT( Artificial Intelligence and Internet of Things ).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  DevOps
&lt;/h2&gt;

&lt;p&gt;DevOps is also becoming more and more popular among software developers and big industries like Google, Facebook and others. It makes the software development process and software maintenance more easy and increase development speed too.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Web Development
&lt;/h2&gt;

&lt;p&gt;As we know, web pages are now becoming more dynamics after Node.JS. This is the always evolving fields and becoming broader. It is divided into front end and back end, but today most web developers do both of the job which lead to full stack web development. Full stack web development is more powerful and now assemble with new technologies such as progressive web app, react native, electron and many other libraries and frameworks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Blockchain
&lt;/h2&gt;

&lt;p&gt;The new technology, which is changing the economic landscape, is called blockchain. The development of cryptography boost the blockchain which became the start of the today cryptocurrencies such as bitcoin. This field will highly affect the future world.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Network Engineering and Cloud Computing
&lt;/h2&gt;

&lt;p&gt;Everyday, more people are connecting to the internet and there are also new newtwork infrastructures are being constructed by huge enterprises. We can already feel the presence of cloud computing which is helping in every aspects of services from different companies.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Cyber security
&lt;/h2&gt;

&lt;p&gt;Today, most of our information are on internet and we are being lived under the thread of cyber crimes. Almost every industries are trying hard to save their customers privacy and information from cyber criminals and cyber security will help them to reach out to their goal.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Database Administration
&lt;/h2&gt;

&lt;p&gt;You may heard of database, which are the structures or techniques most of the user information store using them. User information are always increasing, so need of database administrators will also increase.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Mobile App Development
&lt;/h2&gt;

&lt;p&gt;Today most of the people are using mobile phones and they require the services only available on computers. Most of the enterprises, companies are trying to give their services using mobile apps and there are ton of mobile apps , some are useful and some are not. But a passionate app developer can develop a useful app for their customers.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;h1&gt;
  
  
  Soft Skills
&lt;/h1&gt;

&lt;p&gt;As we know there is no one perfect in every skills in the world, but we can train ourselves to level up our skills which in return the increase in our productivity. Although there are many skills, we don't need to master all those soft skills. By soft skills I mean skills such as time management, habit management, creativity, negotiation and others. We only need to improve some of the main skills. You can read about those skills below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Cognitive flexibility
&lt;/h2&gt;

&lt;p&gt;May be you might thinking that what is cognitive flexibility, right? Cognitive flexibility is actually the ability to change your thinking from one job to another job instantly. May be you have this skill, but those who have very little of that skill should try to develop this skill.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Negotiation
&lt;/h2&gt;

&lt;p&gt;Negotiation is consider as one of the social skills. I think most of us do negotiation at least one time a day or two day or may be a week. This is also an important skill. As technology is advancing rapidly, all people should try to raise their social skills because robots or AI can't have social skills as we have.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Service orientation
&lt;/h2&gt;

&lt;p&gt;As it is named service orientation, it is how we can think from users need not only for current time but also for the future events. This skill is also an important one.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Judgement and decision-making
&lt;/h2&gt;

&lt;p&gt;There are many people who cannot make clear and fair decisions which is unacceptable in today developing industries. If we have to make decision, we need to be honest and have to trust ourselves before making any decision. Actually the main thing is to trust yourself. Be ready for may be difficult but most profitable decision for everyone.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Emotional intelligence
&lt;/h2&gt;

&lt;p&gt;Many people think about that emotional intelligence is not important in business or today industries including me. I was thinking like this, but this is wrong. We need to develop our EQ(Emotional Quotient) if we don't have a recommended level. This is necessary for everyone in any career.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Coordinating with others
&lt;/h2&gt;

&lt;p&gt;This is basically one of the most important social skills which is in demand in any job, mostly in tech industries. This is a vital skill for any tech related person. Most of today schools, colleges, and universities trying to develop this skill by organizing group projects, group trips and other tasks which need more than 2 students in groups.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  People Management
&lt;/h2&gt;

&lt;p&gt;If you become a project manager in a company for a project, you will need to allocate project resources which also include project members. Every enterprise or company need to watch their resources and have to maintain an acceptable level for the industries.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Creativity
&lt;/h2&gt;

&lt;p&gt;As we know creativity is a necessary skill for everyone. Some are not creative type, but they can develop their creativity skill by putting some efforts on art or something like that.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Critical Thinking
&lt;/h2&gt;

&lt;p&gt;Critical thinking is all about logic and reasoning, which are very important in computer science and economy. This is the basic skill and use logic and reasoning to solve different problems with various solutions. Critical thinkers also have to think about the pros and cons of their solutions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Complex Problem Solving
&lt;/h2&gt;

&lt;p&gt;If you have some ideas or solutions to some of the world complex problems, then your skill of solving complex problem will give benefits you then what you have ever imagined.But to solve complex problem you have to start from basic simple problems which will give you experiences.May be you can start by solving some of your daily life problems.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Time Management and Habit Management
&lt;/h2&gt;

&lt;p&gt;As we know, time is valuable. So don't miss any opportunities and always seek for new opportunities and experiences. By managing your time, you can increase your productivity. You can use some schedules or time tables, but most of us never hit our goals. We will need to protect ourselves from distractions which are the main disruptors of our journeys to the our destinations.If we follow our time tables, it will help in developing good habits. We also have to tackle our bad habits.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Learning Management
&lt;/h2&gt;

&lt;p&gt;There is no one who mastered the field he is studying or doing jobs related to that field. Everyone should learn something new to increase your knowledge.So you will need to manage your learning process to maintain the balance between your works and  your learning.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the programming languages, tech fields and soft skills I think need to learn. You have to choose one or more programming languages and tech fields to master. Think of your interests. I hope this blog will help you to find out the path you want to go through this year. I think everyone should consider the develop all of the above soft skills to an acceptable level. Please try hard and think intelligently.&lt;/p&gt;

&lt;p&gt;I wrote this blogs based on the following articles and blogs. If you want to know in details, read the followings and do some googling. I'm waiting for feedback upon this blog post.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.hrvisionevent.com/content-hub/10-job-skills-youll-need-in-2020-and-beyond" rel="noopener noreferrer"&gt;10 Job Skills You’ll Need in 2020 and Beyond&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.com/swlh/the-3-most-important-skills-to-learn-now-to-thrive-in-2020-2e618c5701dc" rel="noopener noreferrer"&gt;The 3 Most Important Skills to Learn Now to Thrive in 2020&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.computer.org/publications/tech-news/trends/programming-languages-you-should-learn-in-2020" rel="noopener noreferrer"&gt;Programming Languages You Should Learn in 2020&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hackr.io/blog/best-programming-languages-to-learn-2020-jobs-future" rel="noopener noreferrer"&gt;10 Best Programming Languages to Learn in 2020 (for Job &amp;amp; Future)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.quora.com/What-are-the-top-IT-skills-to-learn-for-2020" rel="noopener noreferrer"&gt;What are the top IT skills to learn for 2020?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cover Photo by &lt;strong&gt;&lt;em&gt;&lt;a href="https://www.pexels.com/@element5" rel="noopener noreferrer"&gt;Element5 Digital&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt; from &lt;strong&gt;&lt;em&gt;Pexels&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>My First Seed of Blog Post</title>
      <dc:creator>Vijay Kumar</dc:creator>
      <pubDate>Wed, 01 Jan 2020 09:55:32 +0000</pubDate>
      <link>https://forem.com/vijaykumarktg18/my-first-seed-of-blog-post-4e7l</link>
      <guid>https://forem.com/vijaykumarktg18/my-first-seed-of-blog-post-4e7l</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4pdLpXer--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/wh31dhtxha1px6nx2gym.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4pdLpXer--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/wh31dhtxha1px6nx2gym.jpg" alt="Alt Happy New Year 2020" width="700" height="420"&gt;&lt;/a&gt;&lt;/p&gt;
Photo by cottonbro from Pexels



&lt;p&gt;Hello guys!&lt;br&gt;
First I want to say &lt;em&gt;Happy New Year&lt;/em&gt; to all of my friends.&lt;/p&gt;
&lt;h2&gt;
  
  
  Bio
&lt;/h2&gt;

&lt;p&gt;My name is Vijay Kumar. I'm a student from University of Computer Studies, Mandalay. Currently, I'm studying computer technology (computer engineering).&lt;/p&gt;
&lt;h2&gt;
  
  
  Learning
&lt;/h2&gt;

&lt;p&gt;Although I'm a hardware student, I'm learning full stack web development . After all this doesn't matter what you do or who you are. Actually I'm studying full stack web development to make some money during this joyful university life and get some experiences from web projects. &lt;/p&gt;
&lt;h2&gt;
  
  
  Blog
&lt;/h2&gt;

&lt;p&gt;This is my first ever blog and may be reading this blog will be like a block of texts with full of necessities what a good blog should have.I'll try to overcome with those necessities with the help of feedback from all of my friends.I also wanna ask for guidance if anyone found something wrong in any of my blog posts.In my future blogs, I'm going to write full stack web development related topics and some computer science and engineering topics too.&lt;/p&gt;
&lt;h2&gt;
  
  
  New Year Resolution
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jyt467Wo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7beyf64s6t8mvgmohuj4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jyt467Wo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7beyf64s6t8mvgmohuj4.jpg" alt="Alt a note book with some text written on it" width="700" height="420"&gt;&lt;/a&gt;&lt;br&gt;Photo by &lt;strong&gt;&lt;em&gt;&lt;a href="https://www.pexels.com/@freestocks"&gt;freestocks.org&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt; from &lt;em&gt;Pexels&lt;/em&gt;
  &lt;br&gt;
As today is new year day, everyone is goint to make some resolutions. I made mine too. Writing blog post is also included in my resolution. I hope all of my friends have also made some resolution and I wish they gonna meet their goals in near future.&lt;/p&gt;
&lt;h2&gt;
  
  
  Starting my blogging journey
&lt;/h2&gt;

&lt;p&gt;I'm starting to blog on *** Dev Community *** form now and I hope I'll get full support from my senior developers and my friends.&lt;/p&gt;

&lt;p&gt;Thank You Everyone and enjoy this new year's first day.&lt;br&gt;
Please don't forget to comment.&lt;/p&gt;


&lt;div class="ltag__user ltag__user__id__303185"&gt;
  
    .ltag__user__id__303185 .follow-action-button {
      background-color: #080e3b !important;
      color: #ffffff !important;
      border-color: #080e3b !important;
    }
  
    &lt;a href="/vijaykumarktg18" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zPMCQTSQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--jevXXvCI--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/303185/af840728-fd21-43bf-8763-eb6c55ab8508.jpg" alt="vijaykumarktg18 image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/vijaykumarktg18"&gt;Vijay Kumar&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/vijaykumarktg18"&gt;A frontend developer, who is passionate about learning to solve real-world problems using my web dev skills and explore new stuff on the go.💻🎶😍😀&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Cover Photo by &lt;strong&gt;&lt;em&gt;&lt;a href="https://www.pexels.com/@dom-j-7304"&gt;Dom J&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt; from &lt;em&gt;Pexels&lt;/em&gt;&lt;/p&gt;

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