<?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: Shrushti Polekar</title>
    <description>The latest articles on DEV Community by Shrushti Polekar (@shrushti23).</description>
    <link>https://dev.to/shrushti23</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%2F780716%2Fa1807811-9254-43ec-a82f-0ab0db1c111b.jpg</url>
      <title>DEV Community: Shrushti Polekar</title>
      <link>https://dev.to/shrushti23</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shrushti23"/>
    <language>en</language>
    <item>
      <title>More About ‘this’ Keyword in JavaScript</title>
      <dc:creator>Shrushti Polekar</dc:creator>
      <pubDate>Tue, 07 Jun 2022 17:44:33 +0000</pubDate>
      <link>https://dev.to/shrushti23/more-about-this-keyword-in-javascript-4ejg</link>
      <guid>https://dev.to/shrushti23/more-about-this-keyword-in-javascript-4ejg</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8GLFSUkM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cf7d8f4qylyg3zoy7iux.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8GLFSUkM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cf7d8f4qylyg3zoy7iux.png" alt="Image description" width="875" height="618"&gt;&lt;/a&gt;&lt;br&gt;
Whenever any code is executed in JavaScript, it runs inside an Execution Context. The Global Execution Context is the very first Execution Context on the the call stack. The first thing JS Engine does is, it creates Global Execution Context and gives you two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Global Object&lt;/li&gt;
&lt;li&gt;‘this’ keyword 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X_RsA4_y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p595r8990nnb5a8n8sl8.png" alt="Image description" width="549" height="251"&gt;
Suppose if we create a user object with some properties and methods,
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zftpp5Jv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9m0y2y5nekfjpq4zcnr.png" alt="Image description" width="306" height="139"&gt;
on calling the login function , we can see that the this keyword is nothing but user object!
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h_-MXZ8K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o67o5p7hmm02wymew46j.png" alt="Image description" width="382" height="57"&gt;
Now suppose we attach any new method on user, and call it ,
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a698WzZ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kdlk0is46b2r3rn9n95s.png" alt="Image description" width="380" height="69"&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BTbTnZhj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rqkvufcfqah2im2xyin.png" alt="Image description" width="459" height="62"&gt;
hen also the this keyword points to user object!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thus , the ‘this’ keyword is nothing but the object that the function is a property of!&lt;br&gt;
Now suppose we have a regular function ,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KYTC4UOE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ue1n590xli4l5ajacbcp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KYTC4UOE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ue1n590xli4l5ajacbcp.png" alt="Image description" width="354" height="69"&gt;&lt;/a&gt;&lt;br&gt;
on calling the function we can see that the this keyword points to global object.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aBkk0rBn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dg20obdkv9l0284eatti.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aBkk0rBn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dg20obdkv9l0284eatti.png" alt="Image description" width="681" height="90"&gt;&lt;/a&gt;&lt;br&gt;
But that’s not the case with constructor function.&lt;/p&gt;

&lt;p&gt;Lets see this constructor function f2,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8eMHi_lv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1upqx0qw7ai35be3657a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8eMHi_lv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1upqx0qw7ai35be3657a.png" alt="Image description" width="319" height="108"&gt;&lt;/a&gt;&lt;br&gt;
Now if create an object of f2 and log it to the console we get,&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lyXdOydn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hyj0vyf8w3vqn7nvext.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lyXdOydn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hyj0vyf8w3vqn7nvext.png" alt="Image description" width="294" height="32"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--myQSuT3p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/928hry15llpxgfq3lmhv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--myQSuT3p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/928hry15llpxgfq3lmhv.png" alt="Image description" width="231" height="52"&gt;&lt;/a&gt;&lt;br&gt;
Thus we can say that , when dealing with regular functions ,the ‘this’ keyword points to the global object. But in case of constructor function ,it will point to that respective object itself.&lt;br&gt;
Now see the below object obj1,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yYgRx5KO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0a7wmrm4gp1idpgtnck.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yYgRx5KO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0a7wmrm4gp1idpgtnck.png" alt="Image description" width="692" height="218"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j5ofuG6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pljbsyujgt8stgo064u2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j5ofuG6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pljbsyujgt8stgo064u2.png" alt="Image description" width="687" height="126"&gt;&lt;/a&gt;&lt;br&gt;
since the ‘anotherfunction’ is not really associated with obj1(it behaves like a regular function)directly, the ‘this’ keyword inside it points to global object.&lt;/p&gt;

&lt;p&gt;so in this case , how can we make that ‘this’ ,point to obj1?&lt;/p&gt;

&lt;p&gt;Well this can be achieved by arrow functions.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W-rKgZg---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lfsf32bmxtnltu47l934.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W-rKgZg---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lfsf32bmxtnltu47l934.png" alt="Image description" width="709" height="190"&gt;&lt;/a&gt;&lt;br&gt;
Before arrow function, this was done by using bind function,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qOOMLq2p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b9nyrrhrrflb565sickx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qOOMLq2p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b9nyrrhrrflb565sickx.png" alt="Image description" width="708" height="191"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DjPVvdZD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9rvh59bp6w3mmyl0wmtn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DjPVvdZD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9rvh59bp6w3mmyl0wmtn.png" alt="Image description" width="708" height="86"&gt;&lt;/a&gt;&lt;br&gt;
This was all about ‘this’ keyword!!!&lt;/p&gt;

&lt;p&gt;Hope it helps!&lt;/p&gt;

&lt;p&gt;Happy learning!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Event Bubbling and Capturing!</title>
      <dc:creator>Shrushti Polekar</dc:creator>
      <pubDate>Tue, 07 Jun 2022 16:14:43 +0000</pubDate>
      <link>https://dev.to/shrushti23/understanding-event-bubbling-and-capturing-9lb</link>
      <guid>https://dev.to/shrushti23/understanding-event-bubbling-and-capturing-9lb</guid>
      <description>&lt;p&gt;Event Bubbling and Capturing are very important concepts to know if you want to have control over the events fired in DOM!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Aq523u7f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vn5yd5x86x03g7bwsz72.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Aq523u7f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vn5yd5x86x03g7bwsz72.png" alt="Image description" width="880" height="622"&gt;&lt;/a&gt;&lt;br&gt;
 Event propagation in JavaScript takes place in 3 phases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Event Capturing&lt;/li&gt;
&lt;li&gt;Target&lt;/li&gt;
&lt;li&gt;Event Bubbling(default phase)
Step by step, we will understand each of these phases in detail.
Consider we have some nested DOM elements, for example, something like this,
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nR0rdKTw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vqsf6shq49nl0mh11yvl.png" alt="Image description" width="663" height="661"&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;
    &amp;lt;title&amp;gt;Event handling&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="container"&amp;gt;
      &amp;lt;div id="list_container"&amp;gt;
        &amp;lt;ul&amp;gt;
          &amp;lt;li id="item1"&amp;gt;item 1&amp;lt;/li&amp;gt;
          &amp;lt;li id="item2"&amp;gt;item 2&amp;lt;/li&amp;gt;
          &amp;lt;li id="item3"&amp;gt;item 3&amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We have attached click event listeners on all the DOM elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;container = document.querySelector("#container");
list_container = document.querySelector("#list_container");
item1 = document.querySelector("#item1");
item2 = document.querySelector("#item2");
item3 = document.querySelector("#item3");

container.addEventListener("click", () =&amp;gt; {
  console.log("container(red) clicked!");
});
list_container.addEventListener("click", () =&amp;gt; {
  console.log("list container(green) clicked");
});
item1.addEventListener("click", () =&amp;gt; {
  console.log("item 1 clicked!");
});
item2.addEventListener("click", () =&amp;gt; {
  console.log("item 2 clicked!");
});
item3.addEventListener("click", () =&amp;gt; {
  console.log("item  3 clicked!");
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have something like this.&lt;/p&gt;

&lt;p&gt;Now whenever we click item 1 we can see all the event listeners attached to the elements above item 1 (list_container and container) are executed as well.&lt;br&gt;
&lt;a href="https://thumbs.gfycat.com/IllegalCavernousDromaeosaur-mobile.mp4"&gt;https://thumbs.gfycat.com/IllegalCavernousDromaeosaur-mobile.mp4&lt;/a&gt;&lt;br&gt;
We can see in the console, along with the event attached to item1, events attached to other elements above it are also executed!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pqwyQQiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1w27j41e0i6cvrhg0hg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pqwyQQiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1w27j41e0i6cvrhg0hg.png" alt="Image description" width="709" height="81"&gt;&lt;/a&gt;&lt;br&gt;
 &lt;strong&gt;This is nothing but event bubbling!&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lWSZJxAV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ydrn1el4pdyxxipy3jcj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lWSZJxAV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ydrn1el4pdyxxipy3jcj.png" alt="Image description" width="509" height="353"&gt;&lt;/a&gt;&lt;br&gt;
 Just as a bubble bubbles at the top of the glass from the bottom of the glass, in a similar way in a web page event execution takes place from the lowest element to the topmost element!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tz9MCPVZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3hdeiyn4pce3kktr9lny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tz9MCPVZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3hdeiyn4pce3kktr9lny.png" alt="Image description" width="786" height="536"&gt;&lt;/a&gt;&lt;br&gt;
Event capturing&lt;br&gt;
Event capturing is exactly the opposite of Event bubbling!&lt;/p&gt;

&lt;p&gt;In event capturing, events are fired from top to bottom of the DOM tree.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--odZVXnhE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dgp4cseju3o3ad1obrli.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--odZVXnhE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dgp4cseju3o3ad1obrli.png" alt="Image description" width="873" height="529"&gt;&lt;/a&gt;&lt;br&gt;
Whenever we click on item1 the event listener attached to the container gets executed and then the event listener attached to the list_container and finally the target (that’s item1).&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eQV4igM3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0j5tjt89aavc4r10zoo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eQV4igM3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0j5tjt89aavc4r10zoo.png" alt="Image description" width="709" height="87"&gt;&lt;/a&gt;&lt;br&gt;
Capturing functionality can be implemented by simply passing a parameter called ‘true’ in the addEventListener.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;container = document.querySelector("#container");
list_container = document.querySelector("#list_container");
item1 = document.querySelector("#item1");
item2 = document.querySelector("#item2");
item3 = document.querySelector("#item3");

container.addEventListener("click", () =&amp;gt; {
  console.log("container(red) clicked!");
},true);
list_container.addEventListener("click", () =&amp;gt; {
  console.log("list container(green) clicked");
},true);
item1.addEventListener("click", () =&amp;gt; {
  console.log("item 1 clicked!");
},true);
item2.addEventListener("click", () =&amp;gt; {
  console.log("item 2 clicked!");
},true);
item3.addEventListener("click", () =&amp;gt; {
  console.log("item  3 clicked!");
},true);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;stopPropagation&lt;/strong&gt;&lt;br&gt;
We can also control the propagation by using the stopPropagation() function.&lt;/p&gt;

&lt;p&gt;stopPropagation() stops the propagation until the place where it is declared.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;container = document.querySelector("#container");
list_container = document.querySelector("#list_container");
item1 = document.querySelector("#item1");
item2 = document.querySelector("#item2");
item3 = document.querySelector("#item3");

container.addEventListener("click", () =&amp;gt; {
  console.log("container(red) clicked!");
});
list_container.addEventListener("click", (e) =&amp;gt; {
  e.stopPropagation();
  console.log("list container(green) clicked");
});
item1.addEventListener("click", () =&amp;gt; {
  console.log("item 1 clicked!");
});
item2.addEventListener("click", () =&amp;gt; {
  console.log("item 2 clicked!");
});
item3.addEventListener("click", () =&amp;gt; {
  console.log("item  3 clicked!");
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After using stopPropagation() with list_container, we get the following output,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4k2eaSNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gbha7xcjh1g466w66fg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4k2eaSNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gbha7xcjh1g466w66fg.png" alt="Image description" width="709" height="55"&gt;&lt;/a&gt;&lt;br&gt;
 Thus as we can see, event execution stopped after list_container’s event listener.&lt;/p&gt;

&lt;p&gt;This was all about event bubbling and capturing!&lt;br&gt;
Hope this article helps!&lt;/p&gt;

&lt;p&gt;Happy learning! 😃&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/shrushti2000/51bdec64e6e73ad8e4cec3b99ff1d7ae"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Prototypes in JavaScript!</title>
      <dc:creator>Shrushti Polekar</dc:creator>
      <pubDate>Tue, 07 Jun 2022 15:58:17 +0000</pubDate>
      <link>https://dev.to/shrushti23/prototypes-in-javascript-101a</link>
      <guid>https://dev.to/shrushti23/prototypes-in-javascript-101a</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MOBEQq7f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jn7wmvw86tae27a9ika.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MOBEQq7f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jn7wmvw86tae27a9ika.png" alt="Image description" width="880" height="622"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Prototypes is one of the most important pillars in JavaScript! In this article we will understand what are prototypes ,what are global objects , what is this &lt;strong&gt;proto&lt;/strong&gt; property and how inheritance works in JavaScript underneath the hood.&lt;br&gt;
So lets get started without further ado,&lt;br&gt;
When we create a function in JavaScript, JavaScript Engine creates two objects :-&lt;br&gt;
The Function Object itself&lt;br&gt;
The Prototype Object &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yzWnGSj2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y3ut3b21lbhwduiifw7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yzWnGSj2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y3ut3b21lbhwduiifw7a.png" alt="Image description" width="768" height="271"&gt;&lt;/a&gt;&lt;br&gt;
For eg consider this,&lt;br&gt;
Let say we create a function f1() as follows,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y2fp4IAt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfjuhk4ev89op96vmyve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y2fp4IAt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfjuhk4ev89op96vmyve.png" alt="Image description" width="706" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then what JS Engine does is , it creates two objects as mentioned above,&lt;br&gt;
The f1 function object itself and f1 function's Prototype Object,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GRmfrp7v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ntxz9w3j5jfgx1pztevr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GRmfrp7v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ntxz9w3j5jfgx1pztevr.png" alt="Image description" width="834" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now what's this prototype that you can see inside this f1 Object?&lt;br&gt;
Well, JS Engine creates a property on function Object that points to the function's Prototype Object.&lt;br&gt;
We can access the f1 object directly by doing this,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zSE1v9O0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ipzcolokac6brdelatm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zSE1v9O0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ipzcolokac6brdelatm.png" alt="Image description" width="704" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However if we want to access the f1's prototype Object we can access it by using that prototype property,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8WQx-Hdb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e9rcmgoerp9a7yfgytk4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8WQx-Hdb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e9rcmgoerp9a7yfgytk4.png" alt="Image description" width="599" height="92"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now suppose we create a new object from that f1 function&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cJPupiq2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9nv9y74a7cf0832oyw1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cJPupiq2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9nv9y74a7cf0832oyw1d.png" alt="Image description" width="512" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and if we access it , we can see that there is something called as &lt;strong&gt;proto&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hUo7Xpfg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yngrn2525uz8qe688lav.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hUo7Xpfg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yngrn2525uz8qe688lav.png" alt="Image description" width="572" height="81"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;proto&lt;/strong&gt; is property that JS Engine creates for every object ! Well ,this &lt;strong&gt;proto&lt;/strong&gt; property points to the Prototype Object of the function(In this case it will point to f1's Prototype Object)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s2JNjyj8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7aaqrb0s3f1quz7g8k4o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s2JNjyj8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7aaqrb0s3f1quz7g8k4o.png" alt="Image description" width="848" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can check whether f1's prototype property and myobj's prototype property point to the same Prototype Object or not, by doing this,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JkPTKFtG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tifg7t87ej2glk4auxbx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JkPTKFtG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tifg7t87ej2glk4auxbx.png" alt="Image description" width="570" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;as we saw above , that we can access function's prototype Object , in the similar way we can access the f1 Object itself by using a property called constructor. Constructor is a property on the Prototype Object that helps us to access the function itself.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hO3tVFUc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q5tui1cox8xbiwjogz43.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hO3tVFUc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q5tui1cox8xbiwjogz43.png" alt="Image description" width="824" height="435"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XBT1bame--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2x6rbhwyzr1uh5769xmu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XBT1bame--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2x6rbhwyzr1uh5769xmu.png" alt="Image description" width="618" height="51"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Suppose if we want to know who created this object 'myobj' , then we what we need to do is, simply use that constructor property to know this,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0JueA0IB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7w477fp1rlp2hn0zwab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0JueA0IB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7w477fp1rlp2hn0zwab.png" alt="Image description" width="576" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thus we get the f1 function !&lt;br&gt;
We can also create a new object by using this constructor property,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i2BeXX3M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7509zpt8tiy8n2fm0w2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i2BeXX3M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7509zpt8tiy8n2fm0w2m.png" alt="Image description" width="404" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This simply implies , create an object myobj2 by using the same function/constructor who created the object myobj.&lt;br&gt;
Up until now we saw what is this prototype property, what is this &lt;strong&gt;proto&lt;/strong&gt; property and the constructor property , what all things do they point to and what are their uses!&lt;br&gt;
However it is not recommended to use &lt;strong&gt;proto&lt;/strong&gt; property very often!&lt;br&gt;
The Global Object&lt;br&gt;
In JRE ,just as you have a global window object , in the similar way you also have a global functions. And one of those global functions is called Object. Name of the function is Object but the type is function .But since functions are Objects in JavaScript, this is also considered as an Object . I know this sounds a bit confusing!😬&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TvqOfxZf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3accd13trq031k7wzeoy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TvqOfxZf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3accd13trq031k7wzeoy.png" alt="Image description" width="580" height="53"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KVTwWEly--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ijwi7c3yhfpu5hq71f2w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KVTwWEly--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ijwi7c3yhfpu5hq71f2w.png" alt="Image description" width="427" height="76"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nVvg30Wf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ggz3sy4pyoe1s4m6vws0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nVvg30Wf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ggz3sy4pyoe1s4m6vws0.png" alt="Image description" width="698" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Prototype Object!&lt;br&gt;
Lets create a function person and a new p1 object from it,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n17WLXdA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/43vka9q67gur4r6t3orx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n17WLXdA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/43vka9q67gur4r6t3orx.png" alt="Image description" width="454" height="114"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0ITOx5TD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojyoqv9tbb2kt5gt97yw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0ITOx5TD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojyoqv9tbb2kt5gt97yw.png" alt="Image description" width="725" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking at the Person's prototype object, makes us wonder ,who created this Person's prototype object ?&lt;br&gt;
Well it was automatically created by 'new Object'! Person's prototype Object itself has &lt;strong&gt;proto&lt;/strong&gt; property that points to the Global Object's Prototype.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UOhR79bN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dy57d5lb64t5hyb3kjjk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UOhR79bN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dy57d5lb64t5hyb3kjjk.png" alt="Image description" width="865" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Suppose if we try to access any property on p1 object , JS Engine will first try to find it inside p1. If it does not find it there , it will go up the prototype chain by using the &lt;strong&gt;proto&lt;/strong&gt; property of p1 .&lt;br&gt;
p1.&lt;strong&gt;proto&lt;/strong&gt;&lt;br&gt;
If it even does not find it there also , it will again go one step up the prototype chain.&lt;br&gt;
p1.&lt;strong&gt;proto&lt;/strong&gt;.&lt;strong&gt;proto&lt;/strong&gt;&lt;br&gt;
And if it does not find it there as well, then it will return undefined!&lt;br&gt;
Now there's one question , is this prototype chain never ending? Does base object's prototype have a &lt;strong&gt;proto&lt;/strong&gt; property as well?&lt;br&gt;
Well no, it does have &lt;strong&gt;proto&lt;/strong&gt; property ,but it points to null. Lets check this,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9klrrkjR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31euk8wrtlj1zt0p0p26.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9klrrkjR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31euk8wrtlj1zt0p0p26.png" alt="Image description" width="493" height="60"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wyl2wAU7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7pmxmwfaygpw0h2mz62q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wyl2wAU7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7pmxmwfaygpw0h2mz62q.png" alt="Image description" width="736" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Prototypal Inheritance&lt;br&gt;
Inheritance in JS is totally different than other programming languages. Its unlike classical inheritance.&lt;br&gt;
Suppose if we have a Person function (as discussed above) .And now we also have a Teacher function .Teacher will have all the properties of Person.&lt;br&gt;
Initially Person's Prototype as well as Teacher's prototype(&lt;strong&gt;proto&lt;/strong&gt; ) property both are pointing towards base Object's Prototype.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_Q0jtUXy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/99upygzi4cwt0xvys0w9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_Q0jtUXy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/99upygzi4cwt0xvys0w9.png" alt="Image description" width="601" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this case , Teacher and person are not related. Teacher will not posses any property of Person. Well to overcome this, we can make the Teacher's prototype object(&lt;strong&gt;proto&lt;/strong&gt; property) to point towards Person's prototype object.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---4V3sxdV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53xuqn8waf362luuzmnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---4V3sxdV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53xuqn8waf362luuzmnr.png" alt="Image description" width="652" height="58"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YSFPQjg2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7m4u97l0avxl2hxgoq9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YSFPQjg2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7m4u97l0avxl2hxgoq9b.png" alt="Image description" width="599" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now teacher can access all properties of person .&lt;br&gt;
This was all about Prototypes and Prototypal Inheritance!&lt;br&gt;
Hope this article helps!&lt;br&gt;
Happy learning!😀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>More about JavaScript Functions!</title>
      <dc:creator>Shrushti Polekar</dc:creator>
      <pubDate>Thu, 06 Jan 2022 07:14:30 +0000</pubDate>
      <link>https://dev.to/shrushti23/more-about-javascript-functions-4d31</link>
      <guid>https://dev.to/shrushti23/more-about-javascript-functions-4d31</guid>
      <description>&lt;p&gt;We all know functions are group of statements that perform a specific task. Functions in JavaScript exhibit various forms .We have a variety of types in functions in JavaScript , like function expression, Anonymous functions, Arrow functions and IIFE.&lt;br&gt;
Lets get started with some basic function pattern which we normally see in other programming languages as well i.e. normal/regular function definition.&lt;br&gt;
Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function function_name(){
//statements
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fir02s63lfdfamjlt62nu.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%2Fuploads%2Farticles%2Fir02s63lfdfamjlt62nu.JPG" alt="function 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was pretty easy! Now lets have a look at some other types.&lt;br&gt;
&lt;strong&gt;Function Expressions&lt;/strong&gt;&lt;br&gt;
In JavaScript we can create functions and can assign them to variables as well!&lt;br&gt;
Yes , you read it right! We can assign functions to variables.&lt;br&gt;
Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var variable_name =function function_name(){
//statements
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvqo28yeh45fkjme13jn7.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%2Fuploads%2Farticles%2Fvqo28yeh45fkjme13jn7.JPG" alt="function variables"&gt;&lt;/a&gt;&lt;br&gt;
We cannot call sayhi() directly, it results into reference error.&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%2Fuploads%2Farticles%2Fzsc1ef70552seq8w9ylp.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%2Fuploads%2Farticles%2Fzsc1ef70552seq8w9ylp.JPG" alt="function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also remember , function expressions are never hoisted!&lt;br&gt;
So we cannot do something like this.&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%2Fuploads%2Farticles%2Fnx5l88g0yw30nz73oniv.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%2Fuploads%2Farticles%2Fnx5l88g0yw30nz73oniv.JPG" alt="function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This results into TypeError.&lt;br&gt;
&lt;strong&gt;Anonymous Functions&lt;/strong&gt;&lt;br&gt;
Anonymous functions are functions with no specific name.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They can be stored in a variable.&lt;/li&gt;
&lt;li&gt;Can be returned in a function .&lt;/li&gt;
&lt;li&gt;Can be passed in a function.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function(){
 //body of function
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Store an anonymous function in a variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var variable_name = function(){
    //body of function;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fib7e5ln3j0kf289jk5bs.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%2Fuploads%2Farticles%2Fib7e5ln3j0kf289jk5bs.JPG" alt="function"&gt;&lt;/a&gt;&lt;br&gt;
Passing anonymous functions as an argument in JavaScript.&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%2Fuploads%2Farticles%2Fgycarwykc8fc1woanisu.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%2Fuploads%2Farticles%2Fgycarwykc8fc1woanisu.JPG" alt="anonymous functions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now if we call myfunc inside show we get,&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%2Fuploads%2Farticles%2Fn34vvpxdv7hy2l6morus.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%2Fuploads%2Farticles%2Fn34vvpxdv7hy2l6morus.JPG" alt="function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Returning anonymous function&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%2Fuploads%2Farticles%2Fqx2ep2diab3udzraoxxu.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%2Fuploads%2Farticles%2Fqx2ep2diab3udzraoxxu.JPG" alt="function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arrow Functions!&lt;/strong&gt;&lt;br&gt;
Arrow functions were introduced from ES6.&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%2Fuploads%2Farticles%2Fjct5kw5fo7ppd9dnw1mj.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%2Fuploads%2Farticles%2Fjct5kw5fo7ppd9dnw1mj.JPG" alt="arrow functions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was all for this blog!&lt;br&gt;
Hope it helps!&lt;br&gt;
Happy learning!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Playing around with datatypes in JS</title>
      <dc:creator>Shrushti Polekar</dc:creator>
      <pubDate>Sun, 02 Jan 2022 15:31:46 +0000</pubDate>
      <link>https://dev.to/shrushti23/playing-around-with-datatypes-in-js-5coe</link>
      <guid>https://dev.to/shrushti23/playing-around-with-datatypes-in-js-5coe</guid>
      <description>&lt;p&gt;One of the most important component of a programming language is its datatypes. They can be looked upon as a building block of any programming language. In this article we will play around with datatypes in JS and explore more about it!&lt;br&gt;
In JavaScript one of the most interesting feature about variables is that , they are not particularly assosiated with any specific value type and they can assigned and reassigned a value any time.That is why is said that JS is a loosely typed and dynamic language. &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%2Fuploads%2Farticles%2F80o9a701ztn38cy4fmn9.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%2Fuploads%2Farticles%2F80o9a701ztn38cy4fmn9.JPG" alt="datatype1"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;There are primarily two types in JavaScript:-&lt;/strong&gt;&lt;br&gt;
1.Primitives&lt;br&gt;
2.Objects&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primitives&lt;/strong&gt;&lt;br&gt;
Primitives are immutable.There are 7 different Primitives&lt;br&gt;
1.Boolean&lt;br&gt;
2.Null&lt;br&gt;
3.Undefined&lt;br&gt;
4.Number&lt;br&gt;
5.BigInt&lt;br&gt;
6.String&lt;br&gt;
7.Symbol&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Objects&lt;/strong&gt; &lt;br&gt;
Objects are nothing but collection of data in form of key value pairs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;typeof operator&lt;/strong&gt;&lt;br&gt;
The typeof operator helps us to find the type of any unevaluated operand. For eg,&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%2Fuploads%2Farticles%2Ft7n76noy0i4nb7jd85r8.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%2Fuploads%2Farticles%2Ft7n76noy0i4nb7jd85r8.JPG" alt="datatype 2"&gt;&lt;/a&gt;&lt;br&gt;
Function and arrays are also objects in JavaScript!&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%2Fuploads%2Farticles%2Fm9fwu8ihrnlf3umyuwm6.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%2Fuploads%2Farticles%2Fm9fwu8ihrnlf3umyuwm6.JPG" alt="datatype 3"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;BigInt&lt;/strong&gt;&lt;br&gt;
BigInt is a datatype which deals with operations on huge value of integer numbers. BigInt allows to work with numbers beyond the limit of Number primitive.&lt;br&gt;
BigInt is represented by suffix n.&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%2Fuploads%2Farticles%2F1224hm7gqjcg5jghxz1q.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%2Fuploads%2Farticles%2F1224hm7gqjcg5jghxz1q.JPG" alt="bigint"&gt;&lt;/a&gt;&lt;br&gt;
 Note: It is not possible to perform operations on number datatype and bigInt.&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%2Fuploads%2Farticles%2Fksa1wj5tropc57qgchv6.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%2Fuploads%2Farticles%2Fksa1wj5tropc57qgchv6.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Often while writting programs we need to convert data from one form to another. Here are few conversion methods.&lt;br&gt;
&lt;strong&gt;1. Number to String&lt;/strong&gt;&lt;br&gt;
 There are 3 ways to convert a number to string&lt;br&gt;
  consider, const no=10;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;String(no)&lt;/li&gt;
&lt;li&gt;no.toString()&lt;/li&gt;
&lt;li&gt;no+""&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;2.String to Number&lt;/strong&gt;&lt;br&gt;
There are 3 ways to convert a string to number&lt;br&gt;
  consider, const str='10';&lt;br&gt;
1.Number(str);&lt;br&gt;
2.+str&lt;br&gt;
3.parseInt(str)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Methods on Number object&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Number.isInteger(3.5);            //false
Number.parseInt('5.8');           //5
Number.parseFloat('5.86');        //5.86
Number.isNaN(NaN);                //true
Number.isNaN('text');             //false
10.567.toFixed(2)                 //10.57
10.567.toPrecision('3');          //10.6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NaN&lt;br&gt;
NaN is a special type of number which results by invalid mathematical operations. For eg subtracting a string and number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Number.isNaN('text'-10)        //true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Methods on Math object.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Math.abs(-5);                 //5
Math.floor(1.6)               //1
Math.ceil(3.5)                //4
Math.round(3.67)              //4
Math.max(-5,3,8)              //8
Math.min(-5,3,8)              //-5
Math.sqrt(64)                 //8
Math.pow(5,3)                 //125
Math.trunc(-6.3)              //-6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Symbol&lt;/strong&gt; &lt;br&gt;
Symbol represents  a unique identifier.Symbols are used to identify object properties and to add unique property keys to an object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let symbol1=Symbol();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Demystifying working of a JavaScript program!</title>
      <dc:creator>Shrushti Polekar</dc:creator>
      <pubDate>Sat, 01 Jan 2022 14:21:47 +0000</pubDate>
      <link>https://dev.to/shrushti23/demystifying-working-of-a-javascript-program-9og</link>
      <guid>https://dev.to/shrushti23/demystifying-working-of-a-javascript-program-9og</guid>
      <description>&lt;p&gt;Learning a  new programming language can be fun if we know how things are going underneath the hood. In this article we will see how things work around when it comes to execution of a JavaScript Program!&lt;br&gt;
Well you might have heard that everything in JavaScript happens or takes place inside an execution context. Now what exactly is this execution context?? Well, to put it in simple terms we can say execution context is like a container that mainly contains two components viz Memory Component and Code Execution Component.&lt;/p&gt;

&lt;p&gt;Basically, execution of a program takes place in two phases, &lt;br&gt;
1.Creation Phase&lt;br&gt;
2.Code Execution Phase&lt;/p&gt;

&lt;p&gt;We will try to understand these phases with an example.&lt;br&gt;
Consider the below code ,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var firstName='Shrushti';
var surname='Polekar';
function getFullName(firstName,surname){
  const name=firstName+" "+surname;
  return name;
}
var candidateFullName=getFullName(firstName,surname);
console.log(candidateFullName);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 1: Creation Phase&lt;/strong&gt;&lt;br&gt;
First of all a global execution context is created.&lt;br&gt;
In this phase memory will be allocated to variables firstName and surname with a placeholder of undefined. The function  getFullName will also get memory allocated with the actual block of code as placeholder.&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%2Fuploads%2Farticles%2Fhalqid2so6rarb5ew87q.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%2Fuploads%2Farticles%2Fhalqid2so6rarb5ew87q.JPG" alt="execution context"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Code execution phase&lt;/strong&gt;&lt;br&gt;
In this phase the compiler will start executing the code line by line. The variables firstName and surname will be assigned the actual values ie Shrushti and Polekar. Now as soon as the compiler encounters the function call getFullName, a new execution context will be created and the again the same procedure will be repeated of memory allocation. &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%2Fuploads%2Farticles%2Fwj7n9mb4sdm96g4o3zcr.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%2Fuploads%2Farticles%2Fwj7n9mb4sdm96g4o3zcr.JPG" alt="execution context"&gt;&lt;/a&gt;&lt;br&gt;
The function will perform the operation written in its block and return the string value. Thus the variable candidateFullName will get assigned the value -Shrushti Polekar.&lt;br&gt;
After this the execution context will get discarded and remaining code will continue to execute. Finally the global execution context will also get discarded.&lt;/p&gt;

&lt;p&gt;Thus like this the execution contexts are created , executed and discarded untill the global execution context is not finally discarded. &lt;/p&gt;

&lt;p&gt;This was all about working of a JavaScript Code!!! &lt;br&gt;
Happy Coding!&lt;/p&gt;

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