<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Artig on Medium]]></title>
        <description><![CDATA[Stories by Artig on Medium]]></description>
        <link>https://medium.com/@artig9262?source=rss-e616c230355f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3-Lw5e28aKyA3UKQ-TmGSw.jpeg</url>
            <title>Stories by Artig on Medium</title>
            <link>https://medium.com/@artig9262?source=rss-e616c230355f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 00:57:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@artig9262/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Scope and Lexical Environment]]></title>
            <link>https://artig9262.medium.com/scope-and-lexical-environment-f2a0601a8119?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2a0601a8119</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Tue, 18 Jan 2022 16:39:26 GMT</pubDate>
            <atom:updated>2022-01-18T17:09:17.798Z</atom:updated>
            <content:encoded><![CDATA[<p>Note: It is very important for a beginner to understand that JavaScript is synchronous in nature (that is it executes the code one line at a time). If we understand this, the concept of lexical environment will be very clear to us.</p><p><strong>What is scope:</strong></p><p>In English Grammar, the meaning of scope is: <strong>the extent or range of which something is deals</strong> with. The same applies to JavaScript as well, In JavaScript means where we can access a specific variable in the code.</p><p><strong>What is lexical Scoping or lexical environment:</strong></p><p>Lexical means in the hierarchy, To understand the lexical environment of JavaScript, we have to understand execution context, so whenever a code is run in JavaScript Execution Context(Global) . The first step in the execution context is hoisting, <strong>Hoisting is the process of moving the variable and function declaration at the top of the scope. </strong>Now the Execution phase goes through two-phase one is the declaration and another is the execution phase. So in the declaration phase two types of declaration are done one is a variable declaration and another is a function declaration.</p><p>Now let us understand the concepts of lexical Environment in detail:</p><p>Whenever an execution context is created lexical environment is created, the <strong>lexical environment is the local memory along with the lexical environment of its parent</strong>. Let’s understand this part with an example:</p><pre>console.log(abc())<br>let z = 20</pre><pre>function abc(){<br>let a = 10;</pre><pre>function def(){<br>console.log(a)<br>console.log(z)<br>}</pre><pre>def()</pre><pre>}<br></pre><p>So, to understand this code in an easy way we can do one thing, we can read the code line by line, that is how even JavaScript executes the code, the first step is declaration:</p><pre>let z;<br>fn <strong>abc</strong></pre><p>After the declaration phase, comes the execution phase :</p><pre>z=20</pre><p>But whenever a function is called or executed a function execution context is created, the variable inside is declared</p><pre>let a ;<br>fn <strong>def</strong></pre><p>And in the execution phase the value is stored in its memory</p><pre>a=10</pre><p>And after we can see another function execution, so another function execution context is created, but here no variable is declared only console.log is called so now here we will see the value of <strong>“a”</strong> and <strong>“z”, </strong>here we can understand the concept of lexical scope as well:</p><pre>console.log(a) //10<br>console.log(z) //Reference Error:z is not defined</pre><p>So why we get 10 for a and reference error for z, because in the execution phase of def, it looked for the value of a and found that the value of a is not stored in its memory, so since we know the <strong>lexical environment is the local memory along with the lexical environment of its parent</strong> as defined above the def started looking for the value of <strong>a </strong>in its parent memory and found that value of a is stored is in abc(parent) so it executed its value.</p><p>But why we could not get the value of z, because the same happened here as well it looked for the value of z and found that the value of z is not stored in its memory, so since we know the <strong>lexical environment is the local memory along with the lexical environment of its parent</strong> as defined above the def started looking for the value of z in its parent memory and found that value of z is not stored in abc(parent) so it gave an error, because of hoisting, the value of z which was declared using let was not initialized.</p><p>Since <strong>z </strong>was declared with let that is why we got reference error, if we had declared using var, we would have<strong> undefined.</strong></p><p>You can try and see yourself what will you get as the value of z if declared using var.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2a0601a8119" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is hoisting in JavaScript?]]></title>
            <link>https://artig9262.medium.com/what-is-hoisting-in-javascript-6d580b1c6c85?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d580b1c6c85</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Fri, 07 Jan 2022 09:25:34 GMT</pubDate>
            <atom:updated>2022-01-17T19:40:31.538Z</atom:updated>
            <content:encoded><![CDATA[<p>What is hoisting in JavaScript?</p><p>For understanding the concept of hoisting in detail let us first understand the Global execution context.</p><p>Whenever JavaScript executes a piece of code, a Global execution context is created. The GEC(Global Execution Context) is divided into two parts: declaration and execution phase.</p><p>So whenever a variable is declared, JavaScript moves the variable to the top of its scope in the declaration phase. This process is known as hoisting.</p><p>There are two types of hoisting in JavaScript: variable hoisting and functional hoisting.</p><p>Variable Hoisting: The variable hosting in javaScript goes through two phases,i.e. declaration phase and execution phase. There are three ways to create a variable in JavaScript, using var, let, and const. The declaration and execution phase works differently in var and let and const.</p><p>In the declaration phase, if we are creating any variable using var, the memory gets allocated for the variable. The variable gets initialized with a unique value called undefined .</p><pre>console.log(name); // undefined<br>var name; </pre><p>Here we got undefined the value of the name because it has been initialized with undefined.</p><pre>var name=&quot;Elizabeth&quot;<br>console.log(name); // Elizabeth</pre><p>Here we are getting the name Elizabeth because after declaration phase the, there comes the execution phase, so under the hood what happens is that:</p><pre> var name= undefined //delcration phase<br> name=&quot;Elizabeth&quot;    //execution phase <br> console.log(name); // Elizabeth</pre><p>But with let and const JavaScript works differently:</p><pre>let name=&quot;Arya&quot;<br>console.log(name) // Arya</pre><p>Here we are getting the name Arya because under the hood what happens is that:</p><pre>let name;<br>name=&quot;Arya&quot;<br> console.log(name) // Arya</pre><p>But if we try to do this, we will get an error:</p><pre>console.log(name)  //Uncaught ReferenceError: name is not defined<br>let name=&quot;Arya&quot;</pre><p>Because if we are declaring the variable with let, it is not initialized with anything, that is why we get this error.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d580b1c6c85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is copy by value and copy by reference?]]></title>
            <link>https://artig9262.medium.com/what-is-copy-by-value-and-copy-by-reference-3282d9994b8c?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3282d9994b8c</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Wed, 09 Dec 2020 19:26:51 GMT</pubDate>
            <atom:updated>2020-12-14T14:46:09.848Z</atom:updated>
            <content:encoded><![CDATA[<p>For understanding this topic, we have to understand what is a primitive and non-primitive data type.</p><p><strong>What is a Primitive data type?</strong></p><p>Primitive data types are :</p><ol><li>Number</li><li>Boolean</li><li>Undefined</li><li>Strings</li><li>Null</li></ol><p><strong>What is a non-primitive data type?</strong><br>The non-primitive data types are:</p><ol><li>Object</li><li>Function</li><li>Array</li></ol><p>Difference between primitive and non-primitive data types:</p><ol><li>We can store only one value in primitive data types, whereas we can multiple values in non-primitive data types</li><li>In primitive data types, the values are copied by value whereas in non-primitive data types the values are copied by reference.</li><li>Primitive data types are immutable whereas non-primitives are mutable.</li></ol><p>Now, let us understand how copy by value and copy by reference works:</p><p>Whenever we create a variable and store a primitive value in it and in the future if we want to change the value that we have stored inside it, we cannot do it, we can only reassign the variable with another primitive data type value but cannot change the old one. For example:</p><pre>let str1 = &quot;Apple&quot;</pre><pre>let str2 = str1</pre><pre>str2 = &quot;Orange&quot;</pre><pre>console.log(str1) // Apple<br>console.log(str2) // Orange</pre><p>Here we can see that even if we changed the value of str2 from apple to orange when we checked the value of str1 is was still an apple and not orange because primitive data types are copied directly by value into a new variable, so even if both str1 and str2 is having the same value in line no they are not directly related to each other.</p><p>Now, let us understand how copy by reference works, non-primitive data types are copied by reference, copy by reference means to copy by address, So, when we store an object inside a variable, what actually happens is that the object is created somewhere in the memory with some address(let address be 1111) and that address is exactly stored in the variable and the object. For example:</p><pre>let name1 = {firstname: &quot;Kate&quot;, lastname: &quot;Winslet&quot;}</pre><pre>let name2 = name1</pre><pre>name2.firstname =&quot;katty&quot;</pre><pre>console.log(name1.firstname) // Katty</pre><pre>console.log(name2.firstname) // Katty</pre><p>In the above code snippet, we can see that when we have changed the firstname value in the name2 variable the change got reflected in name1 too because objects are copied by reference or address so when copied the value of name1 to name2 the object did not get copied from name1 to name2 what actually got copied was the address(1111) which it was storing, now both name1 and name2 is pointing to the same memory address, so when the value of name2 was changed it was reflected in name1 too.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3282d9994b8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why FlexBox?]]></title>
            <link>https://artig9262.medium.com/why-flexbox-71a0422687c3?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/71a0422687c3</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Mon, 02 Nov 2020 20:12:37 GMT</pubDate>
            <atom:updated>2020-11-06T06:07:15.323Z</atom:updated>
            <content:encoded><![CDATA[<p>First of all, let us start with what is flexbox and why it was introduced?</p><p>Flexbox is used to make any layout flexible. Flexbox was introduced because it was very difficult to position the items using float or inline-block and make them flexible as well.</p><p><strong>Advantages of using flexbox:</strong></p><p>1.Flexbox allows us to align-items and distribute space among the items in a container even though the size of the container is unknown and dynamic.</p><p>2.It provides flexibility to fix the available space.</p><p>3.In flexbox, the items can accommodate (shrink or grow) according to the size of the screen.</p><p><strong>Now let us move ahead and understand the flexbox properties</strong></p><p>Flexbox has a parent(flex-container) and children(flex-items) property, So let&#39;s understand flexbox parent properties in detail:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*QcLw1QH8tZ9yQINUUE8M6w.png" /></figure><p>The different properties accepted by the flex container:</p><p>1.Display: If we want to use flexbox in our layout we need to use display: flex or display:inline-flex property. As soon as we do this the direction children of the flex items become the flex-items.Display: flex will take all the available horizontal space and inline flex will space according to the size of its content. By default, flex-items are laid out in a horizontal direction.</p><p>2.Flex-direction: We can change the direction of the flex-items inside the flex-container using the flex-direction property</p><p>So to understand the flex-direction property properly we need to understand about main-axis and cross-axis</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*dyUeH24-_MAPezw-Cpm18Q.png" /></figure><p>The <strong>main axis</strong> is defined by the direction the <strong>flex</strong>-items are being laid out. By default, the main axis is in a horizontal direction(i.e. from left to right)but we can change the direction of the main axis by applying<strong> flex-direction: column </strong>property. As soon we use this property the main axis runs from top to bottom.</p><p>The different flex-direction properties are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*z6v9RiocdFA7qpENtXbVbA.png" /></figure><p>3.Flex-wrap: It accepts three properties wrap,no-wrap, wrap-reverse.The wrap allows us to break and place the items in multiple lines, by default in flex the items display itself in a single line so with wrap property we can wrap the items in multiple lines. With wrap-reverse, we can wrap the flex-items in a reverse direction.</p><p>4. Flex-flow: It is a shorthand property of flex-direction and flex-wrap.For example flex-flow: row reverse or flex-flow: column no-wrap.</p><p>5.Justify-content: Justify-content property defines how an item should be laid out on the main axis. It controls the alignment of items on the main-axis. By default, the flex-items are placed in a horizontal direction i.e. in a row So justify-content in a row works like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*WyN8s2rSbnFn6sWq_-_v5Q.png" /></figure><p>But we can change the direction of the flex-items in a container and can make it a column, So justify-content works in a column work as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QZvYQKgFQArd0NWLJFprug.gif" /></figure><p>6.Align-items: Align-items works on the cross-axis.It defines how the flex-items will be laid inside a flex-container in a vertical direction for the row and horizontal direction for the column.</p><p>Examples of align-items when the direction of the container is a row are explained below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*SX6ZNDiLumE4HEDeYoOVmw.png" /></figure><p>Example of align-items when the direction of the container is a column.Its works the same as justify-content but in the cross axis :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VncyD4Mivk51_2mB1xUBxA.png" /></figure><p>7. Align-Content: Align-content is used to align the items of a flex-container on a cross-axis.The properties accepted by the align-content are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*vtZROxpcWlkYWNpOCWXRQw.png" /></figure><p>Here flex-container properties end and now let us read about flex-items properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*RpgdVYe4qNVkEePfcW8zHw.png" /></figure><p>The properties accepted by flex-items are:</p><ol><li>Order: With the order property, we can change the order of the flex-items.By default the order of flex-item is 0 so, if we apply order:2 to any item and order:5 to other items, the order: 2 items will come first then order:5 item. We can understand this with an example:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wesn80WMrVqzY_RiUqJB6A.png" /></figure><p>From the above example, we can see that box-7 which has order 1 is in the last place and box-7 which has come just before that and not before any boxes because 7 is greater than 2 and 2 is greater than 0, that is why other boxes are coming first then box with order-2 and then box with order-7</p><p>2.flex-grow: flex-grow property allows a flex item to grow and if there is any extra space inside the container. The default value of flex-grow is 1 if we apply flex-1 to all the flex-items of a container, the width of all the items will be the same.</p><p>3.flex-shrink: flex-shrink property allows the flex-items to shrink when necessary it is used to provide responsiveness to the layout. An example of flex-shrink is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDEHRSp5Ro0AJinvIdAagg.png" /></figure><p>4.flex-basis: flex-basis property is used to provide width to the flex-items.It acts the same as the width property but the only difference is that we cannot provide the auto to the width property but to flex-basis, we can provide auto that means if we explicitly do not provide any width to flex-item it will take the width according to its content. An example of flex-basis is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIFwiBAt0K1OlfZOd3qYvg.png" /></figure><p>5. flex: flex is the shorthand property of flex-grow,flex-shrink, and flex-basis.For example : flex: 0 1 25%;</p><p>6.Align-self:align-self is the same as align-items property like both of them work on cross-axis.The only difference is that align-item is applied flex-container whereas align-self is applied flex-items.</p><p>The disadvantage of flexbox is that it is only one dimensional that is it works on either the horizontal direction or the vertical direction but not on both the direction together, but this disadvantage can be overcome with the grid, but we will learn about the grid in a different article.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71a0422687c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is GitHub flow]]></title>
            <link>https://artig9262.medium.com/what-is-github-flow-fb6d91d29960?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb6d91d29960</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Sun, 27 Sep 2020 14:55:44 GMT</pubDate>
            <atom:updated>2020-09-27T16:03:04.254Z</atom:updated>
            <content:encoded><![CDATA[<p>GitHub flow starts when we create a branch of the master, we create a branch when we want to work on a specific feature and branching helps us work on a specific feature without disturbing the main branch</p><p>The command to create a branch is</p><pre>git branch &lt;branchname&gt;</pre><p>If you want to know more about branching you can read this article:</p><p><a href="https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/about-branches">About branches</a></p><p>after the branch has been created we can work on the feature for which we created the branch.</p><p>The feature can be anything like for example if you want to add a footer to the main website we can create a branch and name it accordingly</p><pre>git branch Add Footer</pre><p>Whenever we add, edit, or delete a file, we are making a commit and adding them to our branch. This process of adding commits keeps track of our progress as we work on a feature branch.</p><p>The command to commit changes is:</p><pre>git commit -m &quot; Add footer to the project&quot;</pre><pre>-m is for the message we want to provide alongwith the commit for whatever changes we have.</pre><p>If we want the project maintainers to consider the changes we have made, we need to raise a pull request, pull request lets us show others the changes we are proposing so they can review and discuss them.</p><p>If you want to know in detail how to raise a pull request, you can read this article:</p><p><a href="https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request">https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request</a></p><p>Once our pull request has been reviewed and the branch passes the tests, we can deploy our changes to verify them in production. If our branch causes issues, we can roll it back by deploying the existing main branch into production. After changes have been verified in production, we can merge our code into the master branch.</p><p>If you want to know more about Github flow you can read this article:</p><p><a href="https://guides.github.com/introduction/flow/">https://guides.github.com/introduction/flow/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb6d91d29960" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hoisting]]></title>
            <link>https://artig9262.medium.com/hoisting-8047d4e6cb3a?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8047d4e6cb3a</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Mon, 07 Sep 2020 10:04:33 GMT</pubDate>
            <atom:updated>2020-09-07T14:04:11.237Z</atom:updated>
            <content:encoded><![CDATA[<p>Hoisting is javaScript’s default behavior of moving the declaration to the top. Javascript only moves the variable declaration to the top, not variable initialization.</p><p>Now, what is a variable declaration and what is variable initialization we will understand with an example</p><pre>var a; // variable declaration <br>a=20 // variable initialization </pre><p>So, whenever we declare a variable and initialize a value to it.JavaScript divides the code into two parts, first declaration and another initialization, and then move the declaration part to the top of the program.</p><p>For Example :</p><pre>var a =10;<br>var b =60;<br>console.log(a)</pre><p>During the compilation phase it becomes something like this:</p><pre>var a;<br>var b;<br>console.log(a)<br>a=10<br>b=60;</pre><p>Here, the value of the console log will be undefined, because during the creation phase the variable a and b was initialized with the value “undefined”.</p><p>The same is with function, if we declare a variable inside a function, JavaScript moves the variable declaration to the top.</p><p>For Example :</p><pre>var h =&quot;Hi!&quot;</pre><pre>console.log(h) // Hi!</pre><pre>function greetting (){</pre><pre>console.log(h) // Hi!</pre><pre>}<br>greeting()</pre><p>Since h is declared globally. It can be accessed anywhere inside the program.</p><p>Let us understand hoisting in functions with another example.</p><pre>var h =&quot;Hi!&quot;</pre><pre>console.log(h) // Hi!</pre><pre>function greetting (){</pre><pre>console.log(h) // undefined</pre><pre>var h = &quot;Hello&quot;</pre><pre>}<br>greeting()</pre><p>With var, we can reassign the same variable with different values, Since h was a global variable the expected output would have been Hello but the outcome was different because inside the function javascript moves the variable declaration to the top, therefore, the value of h was undefined.</p><p>Hoisting of a variable declared with let and const :</p><p>So, when we declare a variable with let or const the variable is not initialized with undefined, instead, no value is assigned to it. At this time the variable stays in the temporal dead zone. So, whenever we try to access the value of a variable before it is declared it will throw a reference error.</p><p>For example :</p><pre>console.log(a) // Reference error a is not defined</pre><pre>let a = 10; </pre><p>But it will not throw an error if we write like this:</p><pre>let a =10;<br>console.log(a) // 10</pre><p>Let us understand why in the above example we got a reference error when try to console.log the value and not in the second example. These variable declarations only become initialized when they are evaluated during their execution. The time between the variable declaration and variable execution is known as Temporal Dead Zone, and if we try to access the variable within this zone we will get a reference error.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8047d4e6cb3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Global and Local variables in javaScript]]></title>
            <link>https://artig9262.medium.com/global-and-local-variables-in-javascript-ecf7262a3526?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecf7262a3526</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Sat, 08 Aug 2020 14:36:43 GMT</pubDate>
            <atom:updated>2020-08-08T14:42:56.083Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Global variables</strong>: Global variables are the variables that are declared outside any function in a program and can be accessed in any function in the program.</p><p>For Example:</p><pre> let myName=&quot;Anna&quot;<br> function callName(){<br>   console.log(myName)// &quot;Anna&quot;<br> }</pre><p>From the above example, we can see that we have declared myName outside the function but we can still access its value from inside the function.</p><p><strong>Local Variables</strong>: Local variables are the variables that are declared inside a function and cannot be accessed outside of a function.</p><p>For Example:</p><pre>function vehicleName(){<br>let vehicle= &quot;car&quot;;<br>}<br>console.log(vehicle) //ERROR //vehicle is not defined</pre><p>From the above example, we can see that the variable that is declared inside of function cannot be accessed outside of a function.</p><p><strong>Conclusion</strong>: The global variable can be declared and accessed of any function, but the local variable can’t be accessed outside of a function block if it is declared inside of a function.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecf7262a3526" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[for-in loop]]></title>
            <link>https://artig9262.medium.com/for-in-loop-b4747c4fd944?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4747c4fd944</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 11:00:17 GMT</pubDate>
            <atom:updated>2020-07-06T11:00:17.896Z</atom:updated>
            <content:encoded><![CDATA[<p>According to MDN: The <strong>for...in statement</strong> iterates over all <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties">enumerable properties</a> of an object that are keyed by strings (ignoring ones keyed by <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol">Symbol</a>s), including inherited enumerable properties.</p><p>Which simply means that for-in loop executes for every key in an object.</p><h3>Syntax</h3><p>The syntax of ‘for..in’ loop is −</p><pre>for (variable in object) {<br>   statement or block to execute<br>}</pre><p>In each iteration, one property from the <strong>object</strong> is assigned to the <strong>variable</strong> and this loop continues till all the properties of the object are exhausted.</p><p>Example of a for-in loop is:</p><pre>const user  =  {<br>   firstName:&#39;Anna&#39;,<br>   lastName:&#39;Williams&#39;,<br>   age:25,<br>   country:&#39;Finland&#39;,<br>  <br>}<br><br><br>for (const key in user) {<br>  console.log(key, user[key])<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4747c4fd944" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[For-of loop]]></title>
            <link>https://artig9262.medium.com/for-of-loop-283db88093f?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/283db88093f</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Sun, 05 Jul 2020 07:55:11 GMT</pubDate>
            <atom:updated>2020-07-05T07:55:11.319Z</atom:updated>
            <content:encoded><![CDATA[<p>According to MDN: The <strong>for...of statement</strong> creates a loop iterating over <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol">iterable objects</a>, including built-in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>, array-like objects (e.g., <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments">arguments</a> or <a href="https://developer.mozilla.org/en-US/docs/Web/API/NodeList">NodeList</a>), <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray">TypedArray</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set">Set</a>, and user-defined iterables. It invokes a custom iteration hook with statements to be executed for the value of each distinct property of the object.</p><p>What this simply means that for-of loop executes for every element in an array.</p><p>Example of the for-of loop is :</p><pre>const array1 = [&quot;Apple&quot;, &quot;Mango&quot;, &quot;Orange&quot;];</pre><pre>for (const element of array1) {<br> console.log(element);<br>}</pre><pre>// expected output: &quot;Apple&quot;<br>// expected output: &quot;Mango&quot;<br>// expected output: &quot;Orange&quot;</pre><p>Conclusion:</p><p>The for-of loop is used for executing every element in an array. If we are not interested in the index of the array a for-of loop is preferable to regular for loop</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=283db88093f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ternary Operator]]></title>
            <link>https://artig9262.medium.com/ternary-operator-2419cb6ab487?source=rss-e616c230355f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2419cb6ab487</guid>
            <dc:creator><![CDATA[Artig]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 11:09:08 GMT</pubDate>
            <atom:updated>2020-07-03T11:09:08.241Z</atom:updated>
            <content:encoded><![CDATA[<p>According to MDN :</p><p>The <strong>conditional (ternary) operator</strong> is the only JavaScript operator that takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is <a href="https://developer.mozilla.org/en-US/docs/Glossary/truthy">truthy</a> followed by a colon (:), and finally, the expression to execute if the condition is <a href="https://developer.mozilla.org/en-US/docs/Glossary/falsy">falsy</a>.</p><p>The syntax of the ternary operator is :</p><pre>condition ? value1: value2</pre><h3>Parameters</h3><p>conditionAn expression whose value is used as a condition.</p><p>value1 :value if the condition is true or <a href="https://developer.mozilla.org/en-US/docs/Glossary/truthy">truthy</a>.</p><p>value2 value if the condition is false or falsy.</p><p>Example of Ternary Operator:</p><pre>const userName: isLogin:&#39;Anna&#39;:null</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2419cb6ab487" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>