<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Siddhant Jha</title>
    <description>The latest articles on DEV Community by Siddhant Jha (@siddhantjha).</description>
    <link>https://dev.to/siddhantjha</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%2F483535%2F357a3880-3d17-4176-8b98-d5fc9fab6830.png</url>
      <title>DEV Community: Siddhant Jha</title>
      <link>https://dev.to/siddhantjha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siddhantjha"/>
    <language>en</language>
    <item>
      <title>My Expedition With JavaScript: Interpretation of JS Scopes</title>
      <dc:creator>Siddhant Jha</dc:creator>
      <pubDate>Mon, 23 Nov 2020 13:41:31 +0000</pubDate>
      <link>https://dev.to/siddhantjha/my-expedition-with-javascript-interpretation-of-js-scopes-48c6</link>
      <guid>https://dev.to/siddhantjha/my-expedition-with-javascript-interpretation-of-js-scopes-48c6</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rd7uz-xS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o2rdgve4sbvioffq5pk5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rd7uz-xS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o2rdgve4sbvioffq5pk5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;h1&gt; Hello Dev World &lt;/h1&gt;
&lt;/h1&gt;

&lt;p&gt;I hope you all are keeping safe and getting adapted to the new normal. I am reinitiating my journey into the world of JavaScript after a break and I thought there is no better way to commit myself to this new endeavor than documenting my up’s and down’s with the most popular programming language out there.&lt;/p&gt;

&lt;h3&gt;
  
  
  Today, I tried to learn about &lt;strong&gt;“Scopes”&lt;/strong&gt; in JavaScript. Here’s what I understood in most condensed form:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Scopes in JavaScript can be understood as &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“A set of rules that defines where you can access a particular value”.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scopes can be divided into two categories:&lt;br&gt;
Global Scope&lt;br&gt;
Local Scope&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Local Scope:&lt;/strong&gt; Whenever you define a variable inside a function its scope gets limited to the function itself i.e. You can’t access that variable outside that function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Global Scope:&lt;/strong&gt; When a variable is declared outside any function and can be accessed by any function whatsoever. Then its scope can be considered as Global Scope.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scopes are determined “Lexically”. It means that function can use a variable defined outside its code block only when the variable is declared beforehand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nested Functions creates a &lt;em&gt;&lt;em&gt;Scope Chain&lt;/em&gt;&lt;/em&gt; that ends at the Global Scope level.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Let’s See This In Action
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2h_Ek1F7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/486x1ksi2oziyog0cvhi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2h_Ek1F7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/486x1ksi2oziyog0cvhi.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above, I have declared a variable &lt;em&gt;“a”&lt;/em&gt; under the carnage of &lt;em&gt;&lt;em&gt;“Global Scope”&lt;/em&gt;&lt;/em&gt; and another variable &lt;em&gt;“b”&lt;/em&gt; under the code block of the function named &lt;em&gt;“add5”&lt;/em&gt;  and the scope of the variable is &lt;em&gt;&lt;em&gt;“Local Scope”&lt;/em&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UbYgL_PH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ojbzom20f4xs4b2nqyyl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UbYgL_PH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ojbzom20f4xs4b2nqyyl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Due to the method of the declaration mentioned above &lt;em&gt;“variable a”&lt;/em&gt; can be used whenever and wherever the user required independent of the code block while &lt;em&gt;“variable b”&lt;/em&gt; can be used inside the function &lt;em&gt;“add5”&lt;/em&gt; only.&lt;/p&gt;

&lt;p&gt;That’s what I have learned today. I will try my best to keep this streak up and running all I need from you guys is support and motivation. Will catch up with you guys in the next post till then &lt;em&gt;“Keep Learning, Keep Growing”&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Namaste&lt;/em&gt;&lt;br&gt;
Siddhant Jha&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>100daysofcode</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
