<?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: Priyanshu Jha</title>
    <description>The latest articles on DEV Community by Priyanshu Jha (@priyanshu_jha_6595c8604e0).</description>
    <link>https://dev.to/priyanshu_jha_6595c8604e0</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3937047%2F11a5f341-1029-4951-bf93-68d6f4c23187.webp</url>
      <title>DEV Community: Priyanshu Jha</title>
      <link>https://dev.to/priyanshu_jha_6595c8604e0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/priyanshu_jha_6595c8604e0"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Priyanshu Jha</dc:creator>
      <pubDate>Fri, 12 Jun 2026 09:18:57 +0000</pubDate>
      <link>https://dev.to/priyanshu_jha_6595c8604e0/-3n8o</link>
      <guid>https://dev.to/priyanshu_jha_6595c8604e0/-3n8o</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/priyanshu_jha_6595c8604e0/execution-context-and-object-context-understanding-window-global-and-this-in-javascript-372f" class="crayons-story__hidden-navigation-link"&gt;Execution Context and Object Context - Clarifying `window` , `global` and `this` in JavaScript.&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/priyanshu_jha_6595c8604e0" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3937047%2F11a5f341-1029-4951-bf93-68d6f4c23187.webp" alt="priyanshu_jha_6595c8604e0 profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/priyanshu_jha_6595c8604e0" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Priyanshu Jha
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Priyanshu Jha
                
              
              &lt;div id="story-author-preview-content-3857403" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/priyanshu_jha_6595c8604e0" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3937047%2F11a5f341-1029-4951-bf93-68d6f4c23187.webp" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Priyanshu Jha&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/priyanshu_jha_6595c8604e0/execution-context-and-object-context-understanding-window-global-and-this-in-javascript-372f" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jun 9&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/priyanshu_jha_6595c8604e0/execution-context-and-object-context-understanding-window-global-and-this-in-javascript-372f" id="article-link-3857403"&gt;
          Execution Context and Object Context - Clarifying `window` , `global` and `this` in JavaScript.
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/beginners"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;beginners&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/oop"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;oop&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/tutorial"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;tutorial&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/priyanshu_jha_6595c8604e0/execution-context-and-object-context-understanding-window-global-and-this-in-javascript-372f" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt;&amp;nbsp;reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/priyanshu_jha_6595c8604e0/execution-context-and-object-context-understanding-window-global-and-this-in-javascript-372f#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            8 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Execution Context and Object Context - Clarifying `window` , `global` and `this` in JavaScript.</title>
      <dc:creator>Priyanshu Jha</dc:creator>
      <pubDate>Tue, 09 Jun 2026 13:14:17 +0000</pubDate>
      <link>https://dev.to/priyanshu_jha_6595c8604e0/execution-context-and-object-context-understanding-window-global-and-this-in-javascript-372f</link>
      <guid>https://dev.to/priyanshu_jha_6595c8604e0/execution-context-and-object-context-understanding-window-global-and-this-in-javascript-372f</guid>
      <description>&lt;h2&gt;
  
  
  Introduction - This article is for clarity
&lt;/h2&gt;

&lt;p&gt;This article is created to give you a &lt;em&gt;grassroots&lt;/em&gt; explanation of what execution context is in JS how it works. What is the relationship between &lt;code&gt;this&lt;/code&gt;, JS Objects and an &lt;strong&gt;Execution Context&lt;/strong&gt;. &lt;br&gt;
If you are a JavaScript developer , or study/know JS , it is not surprising to be confused by &lt;code&gt;this&lt;/code&gt;. That confusion may stem from a hazy understanding of execution context and how it interacts with &lt;code&gt;this&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Reading this post should give you the clarity you need to understand about what execution context, call stack, functions, objects, object context,  &lt;code&gt;this&lt;/code&gt; keyword, &lt;code&gt;window&lt;/code&gt; and &lt;code&gt;global&lt;/code&gt; are, how they &lt;em&gt;relate&lt;/em&gt; and &lt;em&gt;work&lt;/em&gt; with each other, and their &lt;em&gt;differences&lt;/em&gt;.&lt;br&gt;
We will also ask a fundamental question - why objects don't have an execution context of their own and why &lt;code&gt;this&lt;/code&gt; points to them &lt;em&gt;anyway&lt;/em&gt; in execution context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that this is &lt;strong&gt;not&lt;/strong&gt; a complete deep-dive into the ECMAScript spec. But rather a basic overview meant to give you an idea and think with &lt;em&gt;clarity&lt;/em&gt; about &lt;code&gt;this&lt;/code&gt; in JavaScript.&lt;/p&gt;

&lt;p&gt;If you are a JavaScript developer, or like learning things from grassroot basics you may enjoy this article.&lt;/p&gt;


&lt;h2&gt;
  
  
  What is an Execution Context?
&lt;/h2&gt;

&lt;p&gt;To explain simply, understand Execution Context as a &lt;strong&gt;metadata&lt;/strong&gt; &lt;em&gt;wrapper/container&lt;/em&gt; for a block of code that contains all the necessary data to execute that block of code.&lt;br&gt;
It holds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables, arguments, and functions inside that function.&lt;/li&gt;
&lt;li&gt;Rules for how to look things up (scope).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We call execution context metadata because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It describes and governs how the other code behaves (variables, &lt;code&gt;this&lt;/code&gt;, scoping rules).&lt;/li&gt;
&lt;li&gt;This is the internal, behind-the-scenes mechanism of the engine.&lt;/li&gt;
&lt;li&gt;It exists for the engine's bookkeeping, not for direct programmer manipulation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are three main types of execution context: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Global Execution Context: The default, base context. It is created when a script first starts running. It creates a global object (&lt;code&gt;window&lt;/code&gt; in browsers, &lt;code&gt;global&lt;/code&gt; in Node.js) and sets &lt;code&gt;this&lt;/code&gt; to that global object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Function Execution Context: A brand new context is created every time a function is called. Each function call get their own execution context, completely separate from other contexts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Eval Execution Context: Created when code is executed inside the eval() function. (Generally rare and not recommended for security/performance reasons).&lt;br&gt;
&lt;em&gt;We are going to ignore eval execution context in this article.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is how the JavaScript engine sees an Execution Context (conceptually)&lt;/span&gt;

&lt;span class="nx"&gt;ExecutionContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Internal fields (you never see these directly):&lt;/span&gt;
    &lt;span class="na"&gt;VariableEnvironment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;    &lt;span class="c1"&gt;// Where local variables live&lt;/span&gt;
    &lt;span class="na"&gt;LexicalEnvironment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;     &lt;span class="c1"&gt;// For scope chain&lt;/span&gt;
    &lt;span class="na"&gt;ThisBinding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt;&lt;span class="p"&gt;?,&lt;/span&gt;                &lt;span class="c1"&gt;// ← This stores the current 'this' value&lt;/span&gt;

    &lt;span class="c1"&gt;// Other internal metadata...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// When your code uses 'this', the engine looks up the ThisBinding field&lt;/span&gt;

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

&lt;/div&gt;

&lt;h3&gt;
  
  
  Call Stack : Where and How are the Execution Contexts Stored ?
&lt;/h3&gt;

&lt;p&gt;Everytime we call a function, a new execution context is created, but execution context is a data(metadata), creating and storing it consumes &lt;em&gt;memory&lt;/em&gt; - &lt;strong&gt;RAM (Random Access Memory)&lt;/strong&gt; to be specific. It is created when you &lt;u&gt;run the code&lt;/u&gt;. The amount used by a single context memory is small (relatively), but it's &lt;u&gt;very real&lt;/u&gt;. The contexts are organized in RAM through a list called &lt;strong&gt;Call Stack&lt;/strong&gt;. &lt;br&gt;
When the program runs, call stack organises the execution context in a LIFO (Last In First Out) fashion. Each function that are called have their metadata pushed to the top of the stack and are removed after the function executes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;globalVar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm global&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;outer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;outerVar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm outer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;inner&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;innerVar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm inner&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;innerVar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// inner's Execution Context is on top of stack&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;inner&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// inner's context is created and pushed&lt;/span&gt;
  &lt;span class="c1"&gt;// inner's context is popped off the stack after it finishes&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;outer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// outer's context is created and pushed&lt;/span&gt;
&lt;span class="c1"&gt;// outer's context is popped off the stack after it finishes&lt;/span&gt;

&lt;span class="c1"&gt;// Global Execution Context remains until the program ends.&lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Do Objects have an Execution Context of their Own?
&lt;/h3&gt;

&lt;p&gt;Reading all this, you might wish to ask , or perhaps I should clarify : &lt;strong&gt;Do objects have a execution context of their own? Just like functions do?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The answer is No. Execution contexts track the &lt;strong&gt;Flow of Control&lt;/strong&gt;, not the structure of data. Objects are data types that simply exist, they don't do anything.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Entity&lt;/th&gt;
&lt;th&gt;Creates Execution Context?&lt;/th&gt;
&lt;th&gt;Why?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Function&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;YES&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Functions &lt;strong&gt;do&lt;/strong&gt; something when called; calling them triggers a new context to manage their execution.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Object&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;NO&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Objects &lt;strong&gt;are&lt;/strong&gt; something (data storage); they exist in memory but do not execute code on their own.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Constructor&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;YES&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A constructor is a specific type of function. Using &lt;code&gt;new&lt;/code&gt; invokes it, which creates a new execution context to initialize the instance.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Prototype&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;NO&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Prototypes &lt;strong&gt;are&lt;/strong&gt; something (inheritance blueprints); they define shared behavior but are not executed directly.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// An object literal - NO execution context created&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Toyota&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  &lt;span class="c1"&gt;// The function INSIDE will get a context when CALLED&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; starting`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// The object 'car' just sits in memory as data.&lt;/span&gt;
&lt;span class="c1"&gt;// No "execution" happens when you merely access it:&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Just data lookup, no new context&lt;/span&gt;

&lt;span class="c1"&gt;// But when you CALL the function:&lt;/span&gt;
&lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// YES! NEW execution context created for this function call&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The &lt;code&gt;This&lt;/code&gt; Keyword.
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;this&lt;/code&gt; is a special keyword in JavaScript, that points to the object that is currently the context of execution. This is an implicit parameter. That's all.&lt;/p&gt;

&lt;p&gt;So what does that mean? As we already discussed, an object does not have an execution context, it does not do anything.&lt;br&gt;
Here, the statement "Object that is currently the context of execution" &lt;em&gt;means&lt;/em&gt; The object that the current function is acting or operating upon. Or it can be said as ' &lt;code&gt;this&lt;/code&gt; refers to the object that is calling the function. '&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Toyota&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;showBrand&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;showBrand&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Output: "Toyota"&lt;/span&gt;
&lt;span class="c1"&gt;// 'this' refers to 'car' because 'car' called the function.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Context Object (semantic) --&amp;gt; "The object that the function is currently working on behalf of".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We know functions have their own context as metadata , now every executional context has a &lt;code&gt;thisBinding&lt;/code&gt; property that lists the object that is calling the running function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The internal Execution Context (in the JavaScript engine) looks like this:       &lt;/span&gt;
&lt;span class="c1"&gt;// (You never see this directly)                                                   &lt;/span&gt;

&lt;span class="nx"&gt;ExecutionContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;VariableEnvironment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* local variables */&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;LexicalEnvironment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* scope chain */&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;ThisBinding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// ← 'this' is a PROPERTY of the execution context&lt;/span&gt;
    &lt;span class="c1"&gt;// ↑ 'this' does NOT point TO the context, &lt;/span&gt;
    &lt;span class="c1"&gt;//   'this' is a VALUE INSIDE the context&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// In your code:&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// This gives you the ThisBinding value&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Anoter example,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Think of it this way:&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;executionContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;           &lt;span class="c1"&gt;// Internal (you can't access this)&lt;/span&gt;
    &lt;span class="na"&gt;variableEnv&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;scopeChain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...],&lt;/span&gt;
    &lt;span class="na"&gt;thisBinding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;myObject&lt;/span&gt;            &lt;span class="c1"&gt;// ← 'this' is just a property&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// When you write 'this' in your code:&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;    &lt;span class="c1"&gt;// You get executionContext.thisBinding&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;So, Why is this stored as &lt;code&gt;thisBinding&lt;/code&gt; in Execution Context Metadata?&lt;/strong&gt;&lt;br&gt;
Because this can to be &lt;strong&gt;different&lt;/strong&gt; for each function call, even when calling the &lt;em&gt;same&lt;/em&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;A&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;B&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;obj1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;obj1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// "A" (this = obj1)&lt;/span&gt;
&lt;span class="nx"&gt;obj2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// "B" (this = obj2) — same function, different this!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;this&lt;/code&gt; is determined at call time, not definition time.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Why is &lt;code&gt;this&lt;/code&gt; important ?
&lt;/h3&gt;

&lt;p&gt;Importance 1: Method Reusability&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Without 'this', you'd need separate functions for each object&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;alice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hi from Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hi from Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="c1"&gt;// Duplicate code everywhere!&lt;/span&gt;

&lt;span class="c1"&gt;// With 'this', one function works for ALL objects&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;reusableGreet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Hi from &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;alice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;reusableGreet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;bob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;reusableGreet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// One function, infinite objects!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Importance 2: Object-Oriented Programming&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// Without 'this', constructors couldn't work&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// 'this' allows us to refer to "the object being created"&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;birthday&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Updates the specific instance&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;alice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;alice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// Only alice's age increases to 31&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;alice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 31&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;    &lt;span class="c1"&gt;// 25 (unchanged)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Importance 3: Dynamic Context&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 'this' allows functions to work with different objects dynamically&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;updateProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;property&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;

&lt;span class="c1"&gt;// Same function, three different targets&lt;/span&gt;
&lt;span class="nx"&gt;updateProperty&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;first&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;updateProperty&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;second&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;updateProperty&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;third&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;property&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// "first"&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;property&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// "second"&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;property&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// "third"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Importance 4: Event Handling (Browser)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 'this' lets event handlers know WHICH element was clicked&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// 'this' is the specific button that was clicked&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;disabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; was clicked`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// Without 'this', you'd need to pass the element manually every time&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Important:
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;strong&gt;arrow function&lt;/strong&gt; is an exception to the rule of &lt;code&gt;this&lt;/code&gt; referring to the calling object.&lt;br&gt;
Arrow functions, &lt;em&gt;inherit&lt;/em&gt; &lt;code&gt;this&lt;/code&gt; from the surrounding (parent) execution context — at &lt;em&gt;definition time&lt;/em&gt;, not call time.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;My Object&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;regularFunc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// `this` = obj (because of dot rule)&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;arrowFunc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// `this` = whatever it was OUTSIDE obj&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;regularFunc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// "My Object" ✅&lt;/span&gt;
&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;arrowFunc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;   &lt;span class="c1"&gt;// undefined (or global name) — not "My Object"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Trivia :
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;List =&amp;gt; &lt;code&gt;global&lt;/code&gt; vs &lt;code&gt;window&lt;/code&gt; Available APIs:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// BROWSER window contains:&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;      &lt;span class="c1"&gt;// Show popup&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;     &lt;span class="c1"&gt;// DOM API&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt; &lt;span class="c1"&gt;// Client storage&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;      &lt;span class="c1"&gt;// Network requests&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;history&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;

&lt;span class="c1"&gt;// NODE.JS global contains:&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;    &lt;span class="c1"&gt;// Module loading&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;module&lt;/span&gt;       &lt;span class="c1"&gt;// Current module&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;      &lt;span class="c1"&gt;// Module exports&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;      &lt;span class="c1"&gt;// Process info&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Buffer&lt;/span&gt;       &lt;span class="c1"&gt;// Binary data&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setImmediate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;    &lt;span class="c1"&gt;// Current directory path&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;__filename&lt;/span&gt;   &lt;span class="c1"&gt;// Current file path&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Objects exist in heap memory, don't confuse Heap with Call Stack:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Memory Area&lt;/th&gt;
&lt;th&gt;Stores&lt;/th&gt;
&lt;th&gt;Execution Context?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Call Stack&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Execution contexts (function calls), variables, primitives&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;YES&lt;/strong&gt; - Grows/shrinks as functions run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Heap&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Objects, arrays, prototypes, closures&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;NO&lt;/strong&gt; - Persistent data storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Call Stack&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fast, fixed-size, LIFO (Last-In, First-Out)&lt;/td&gt;
&lt;td&gt;Small, organized&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Heap&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Slower, flexible, no fixed order&lt;/td&gt;
&lt;td&gt;Large, unstructured&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Here's another nice table/graph:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="cm"&gt;/*
┌─────────────────────────────────────────────┐
│         Execution Context (internal)        │
├─────────────────────────────────────────────┤
│ • VariableEnvironment                       │
│   - local variables                         │
│   - function declarations                   │
│                                             │
│ • LexicalEnvironment                        │
│   - scope chain references                  │
│                                             │
│ • ThisBinding ───────┐                      │
└──────────────────────│──────────────────────┘
                       │
                       │ (points to)
                       ↓
              ┌─────────────────┐
              │  The value of   │
              │    'this'       │
              │  in your code   │
              └─────────────────┘
*/&lt;/span&gt;

&lt;span class="c1"&gt;// In your code:&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;  &lt;span class="c1"&gt;// Accesses the ThisBinding from the current execution context&lt;/span&gt;

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

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;If you take a &lt;code&gt;this.xyz&lt;/code&gt; here are some things it can refer to:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 1. A regular object (most common)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;describe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;     &lt;span class="c1"&gt;// 'this' = person object&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                 &lt;span class="c1"&gt;// Modifies person.age&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// 'this' points to person&lt;/span&gt;

&lt;span class="c1"&gt;// 2. The global object (window/global)&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;showGlobal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;xyz&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// If xyz exists on global&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;showGlobal&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// 'this' = global object (window in browser)&lt;/span&gt;

&lt;span class="c1"&gt;// 3. undefined (in strict mode)&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;showStrict&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// undefined&lt;/span&gt;
    &lt;span class="c1"&gt;// this.xyz would throw TypeError!&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;showStrict&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// 4. A primitive value (string, number, boolean)&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;showPrimitive&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Could be "hello", 42, or true&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// If string, logs its length&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;showPrimitive&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 'this' = "hello" (auto-boxed to String object)&lt;/span&gt;

&lt;span class="c1"&gt;// 5. null or undefined (intentionally)&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;showNull&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// null&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;showNull&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 'this' = null&lt;/span&gt;

&lt;span class="c1"&gt;// 6. A new empty object (with constructor)&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 'this' = brand new empty object&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;xyz&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;custom&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Adds property to new object&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;alice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 'this' points to new object&lt;/span&gt;

&lt;span class="c1"&gt;// 7. Whatever you explicitly bind (using bind, call, apply)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;boundFunction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;showGlobal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;xyz&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;custom value&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nf"&gt;boundFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// 'this' = { xyz: "custom value" }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;A complete picture:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*
1. OBJECTS exist in heap memory
   - They just hold data (properties)
   - They don't "do" anything
   - They have NO execution context

2. FUNCTIONS also exist in heap memory
   - They contain code
   - They are inert until called

3. EXECUTION CONTEXTS exist temporarily on call stack
   - Created when functions are CALLED
   - Contain metadata for that specific call
   - Include thisBinding field

4. thisBinding stores a REFERENCE to an object
   - Connects the function call to data
   - Allows the function to work with different objects
   - The referenced object remains just an object (no context)
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Credits to: AI assistant - DeepSeek.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;If you actually read this far Thank You Very Much! This is my second article written, leave a comment if you enjoyed it or found anything problematic.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>oop</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Use Portable Git without Administrator Privileges on Windows OS</title>
      <dc:creator>Priyanshu Jha</dc:creator>
      <pubDate>Sun, 31 May 2026 12:18:46 +0000</pubDate>
      <link>https://dev.to/priyanshu_jha_6595c8604e0/use-portable-git-without-windows-admin-rights-on-windows-37nf</link>
      <guid>https://dev.to/priyanshu_jha_6595c8604e0/use-portable-git-without-windows-admin-rights-on-windows-37nf</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to Portable Git (Thumbdrive install)
&lt;/h2&gt;

&lt;p&gt;You can use Git-- the version control system as a &lt;strong&gt;portable&lt;/strong&gt; software on Windows , the portable git can acts same as normal git but without needing administrator privileges for installation, moreover you can carry it around on a USB flash drive with you, and use it with different computers.&lt;/p&gt;

&lt;p&gt;This article explains what Portable Git is and why it’s useful, and walks through downloading, extracting, and using it. You’ll learn how to launch Git from a thumb drive, verify it’s working, and even adjust your system &lt;code&gt;PATH&lt;/code&gt; so your PC recognizes it. In the end you will be shown some methods so that you don't have to manually set its PATH each time you use your thumbdrive. (We assume a 64-bit x64 Windows PC – if you have an ARM64 Windows device, use the ARM64 Portable Git version.).  &lt;/p&gt;

&lt;h3&gt;
  
  
  We assume you have :
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A 64-bit (x86_64/AMD64) or 64-bit ARM (ARM64) Windows computer running Windows 10/11.
&lt;/li&gt;
&lt;li&gt;Intermediate Windows knowledge: navigating folders, using Command Prompt, and setting environment variables.
&lt;/li&gt;
&lt;li&gt;A USB flash drive (or other portable storage) with enough space (about 60 MB free) for Git.
&lt;/li&gt;
&lt;li&gt;(Optional) Administrator access on your PC is &lt;em&gt;not&lt;/em&gt; needed to run Portable Git, which is one of its main advantages.
&lt;/li&gt;
&lt;/ul&gt;




&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Important:&lt;/strong&gt; Do not store or run a portable Git environment on a cheap, low-quality USB flash drive. Git performs frequent, small read/write operations that will quickly degrade cheap flash memory, leading to corrupted repositories and severe performance lag.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Minimum USB Drive Standards for Git
&lt;/h3&gt;

&lt;p&gt;If you must run Git from a USB drive, ensure it meets these bare minimum specifications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Interface&lt;/strong&gt;: USB 3.0 or higher.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Type&lt;/strong&gt;: Solid State Flash (NAND) or "SSD-grade" flash controllers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speed Profile&lt;/strong&gt;: Minimum 100 MB/s sequential write speed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Random I/O&lt;/strong&gt;: High 4K random read/write performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Quality&lt;/strong&gt;: Metal housing for heat dissipation during heavy indexing.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What is portable Git ?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Portable Software&lt;/strong&gt; is an application that runs without any installation into the &lt;em&gt;main memory&lt;/em&gt; or &lt;em&gt;C Drive&lt;/em&gt; where the program files are stored , instead it stores all its files inside its own folder, which we can carry in a storage device of our choice. &lt;/p&gt;

&lt;p&gt;Git for Windows offers a &lt;em&gt;thumbdrive edition&lt;/em&gt; specifically for this use case. &lt;strong&gt;Portable Git&lt;/strong&gt; is simply the standard Windows Git client packaged so it can run from a USB drive. Because it does not modify the Windows registry or require an installer; it leaves no traces on the host computer and runs in isolation. &lt;/p&gt;

&lt;h3&gt;
  
  
  Why use it ?
&lt;/h3&gt;

&lt;p&gt;Many Organisations block Administrator access becuause of Software Control, Licensing, Maintenance , Data Protection, Legal Safety Compliance concerns. Portable Git allows you to safely get around that.&lt;/p&gt;

&lt;p&gt;Using Portable Git is handy in many scenarios: for example, if you want to use Git on a school, work, or shared computer where you can’t install software. You just plug in your flash drive, run Git, and work in any directory (even on the PC’s local drives) as if Git were installed. This keeps your Git environment and history in one place that you control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No installation or admin rights needed&lt;/li&gt;
&lt;li&gt;Portable across machines.&lt;/li&gt;
&lt;li&gt;No changes to system registry.&lt;/li&gt;
&lt;li&gt;Consistent environment on any PC.&lt;/li&gt;
&lt;li&gt;Easy to carry your repositories.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You must manage updates manually.&lt;/li&gt;
&lt;li&gt;Portable git can be slightly slower on a USB drive.&lt;/li&gt;
&lt;li&gt;If the PC has a different default Git installed, you may need to adjust &lt;code&gt;PATH&lt;/code&gt;; you will not get automatic shell integration (e.g. Git Bash) unless you launch it from the USB.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Do you &lt;em&gt;need&lt;/em&gt; portable git?
&lt;/h2&gt;

&lt;p&gt;If a computer already has a properly configured Git installation, most users may not need Portable Git at all.&lt;/p&gt;

&lt;p&gt;A standard installation is usually simpler for everyday development.&lt;/p&gt;

&lt;p&gt;Portable Git is most useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There is no Git and administrator installation is restricted&lt;/li&gt;
&lt;li&gt;Users need isolated/temporary Git environments&lt;/li&gt;
&lt;li&gt;You want Latest or your preffered Git version &lt;/li&gt;
&lt;li&gt;System modifications needs be avoided&lt;/li&gt;
&lt;li&gt;Git must be carried between multiple computers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In other words, Portable Git is mainly about flexibility and portability rather than replacing a normal Git installation in all situations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Downloading Portable Git
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;On a Windows PC, open your web browser and go to the &lt;a href="https://git-scm.com/download/win" rel="noopener noreferrer"&gt;Git for Windows download page&lt;/a&gt;.
&lt;/li&gt;
&lt;li&gt;Choose the &lt;strong&gt;“Portable (“thumbdrive edition”)&lt;/strong&gt; link for your architecture (either “x64 Portable” or “ARM64 Portable”)【25†L46-L54】. This will download a self-extracting archive file (around &lt;strong&gt;56–57 MiB&lt;/strong&gt; for version 2.54, roughly 60 MB) to your Downloads folder. (For example, the file might be named &lt;code&gt;PortableGit-2.54.0-64-bit.7z.exe&lt;/code&gt; for x64.)
&lt;/li&gt;
&lt;li&gt;Confirm the download finished. You should see something like &lt;code&gt;PortableGit-*-bit.7z.exe&lt;/code&gt; in your Downloads folder.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At this point, you have a single &lt;code&gt;.7z.exe&lt;/code&gt; file which is the portable Git package. It’s not installed yet; next we extract it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extracting Portable Git
&lt;/h2&gt;

&lt;p&gt;Double-click the downloaded &lt;code&gt;PortableGit-*.7z.exe&lt;/code&gt; file. A file extraction wizard should open (this is a 7-Zip self-extractor).  &lt;/p&gt;

&lt;p&gt;When prompted for a destination, the default location is &lt;code&gt;C:\Users\priyanshu\Downloads\PortableGit&lt;/code&gt; since this is a "&lt;strong&gt;portable&lt;/strong&gt;" Git we are dealing with, we do NOT install it in &lt;em&gt;program files&lt;/em&gt; of the &lt;em&gt;main memory&lt;/em&gt; (the default location you see as listed), it requires administrator permissions and other ramifications, instead choose a folder on your USB drive or other storage of your own choice. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F77wye02v2qmkavan3tse.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F77wye02v2qmkavan3tse.png" alt="Install Popup screenshot" width="799" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter your preferred location , click &lt;strong&gt;Extract&lt;/strong&gt; or &lt;strong&gt;Unzip&lt;/strong&gt;. The program will unpack Git’s files into your chosen folder.&lt;br&gt;&lt;br&gt;
For our purposes we will extract it into an E drive (NVME SSD) as a portablity example and proof to show you first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fj0i3hmy74gghe710cm93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fj0i3hmy74gghe710cm93.png" alt=" " width="780" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can check if Git exists in your computer PATH or what version of Git it has with &lt;code&gt;Git --version&lt;/code&gt; and where is it stored in your PATH as via &lt;code&gt;where git&lt;/code&gt; command. &lt;br&gt;
More on PATH later.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note : It's possible that the first time your extraction may fail, don't worry and go ahead and try again, sometimes the extraction fails because you may not have created the &lt;em&gt;PortableGit&lt;/em&gt; folder , e.g. in &lt;code&gt;E:\Test-Folder\PortableGit&lt;/code&gt;  the folder &lt;em&gt;PortableGit&lt;/em&gt; may not be created. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Portability Test
&lt;/h2&gt;

&lt;p&gt;Now let's perform a portability test.&lt;/p&gt;

&lt;p&gt;We will cut and paste the Portable Git folder into a removable USB flash drive, and then test whether Git still works correctly from the new location.&lt;/p&gt;

&lt;p&gt;This helps verify that Portable Git can run independently without requiring installation or administrator access.&lt;/p&gt;

&lt;p&gt;After moving the folder to the USB drive, open Command Prompt inside the Portable Git directory and run:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fniyedm4l86iqdp9rqwp3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fniyedm4l86iqdp9rqwp3.png" alt="screenshot description" width="794" height="648"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Running Portable Git and Checking It Works
&lt;/h3&gt;

&lt;p&gt;At &lt;code&gt;F:\PortableGit&lt;/code&gt; the portable Git is moved to and available, now we do a test run by running &lt;strong&gt;Git Command Prompt&lt;/strong&gt; from the folder without seeking any permissions.&lt;/p&gt;

&lt;p&gt;👉 Double click &lt;code&gt;git-cmd.exe&lt;/code&gt; , a command line interface should appear. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In this Git CMD window, type:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;  &lt;span class="kd"&gt;git&lt;/span&gt; &lt;span class="na"&gt;--version
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see output like &lt;code&gt;git version 2.54.0.windows.1&lt;/code&gt; (version number may vary). This confirms Git is working.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next, type:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;  &lt;span class="nb"&gt;where&lt;/span&gt; &lt;span class="kd"&gt;git&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows the path(s) where your Git is executing from. In the Git CMD shell, it will usually point to your USB path (e.g. &lt;code&gt;F:\PortableGit\cmd\git.exe&lt;/code&gt;), indicating you’re using the portable Git. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is PATH, Git-CMD , Git-Bash ?
&lt;/h2&gt;

&lt;p&gt;### PATH &lt;br&gt;
 PATH is an environment variable in operating systems (Linux, macOS, Windows) that tells your system where to look for executable programs when you type a command.&lt;br&gt;
 Simply put, they are a bundle of directories to find and recognise commands in a command line interface.&lt;br&gt;
 Since portable git resides in a removable USB drive, it is not added to PATH. &lt;/p&gt;

&lt;p&gt;### Git-CMD &lt;br&gt;
 Git-CMD.exe Is a file you find in a portable git folder right alongside Git-Bash.exe, double clicking this file opens a command prompt which is simply a windows command prompt but with PATH configured for your portable git.&lt;br&gt;
 ### Git-Bash &lt;br&gt;
 Git Bash is a Unix/Linux style terminal that runs on Windows. &lt;/p&gt;

&lt;p&gt;It supports:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Linux Commands on Windows&lt;/li&gt;
&lt;li&gt;Git Commands (pre-configured) [Just like Git-CMD]&lt;/li&gt;
&lt;li&gt;Shell Scripting&lt;/li&gt;
&lt;li&gt;Pipes and Redirection&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use this if you are more familiar with Linux OS, Shell, or prefer the power of Linux&lt;/p&gt;

&lt;h3&gt;
  
  
  Git Bash vs Windows CMD vs Git CMD
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Windows CMD&lt;/th&gt;
&lt;th&gt;Git CMD&lt;/th&gt;
&lt;th&gt;Git Bash&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Git commands&lt;/td&gt;
&lt;td&gt;✗&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows commands (dir, copy)&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;td&gt;Partially&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux commands (ls, cat, grep)&lt;/td&gt;
&lt;td&gt;✗&lt;/td&gt;
&lt;td&gt;✗&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shell scripting&lt;/td&gt;
&lt;td&gt;✗&lt;/td&gt;
&lt;td&gt;✗&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pipes and redirection&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;✓ Full&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Access all drives&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Powered by&lt;/td&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;MINGW (Linux tools)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Setting Git to PATH
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Do you need it ?
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Depends&lt;/strong&gt; on : &lt;br&gt;
 Do you find it convenient to have use your portable git from anywhere on working device - PowerShell, Command Prompt, VS Code terminal ? Then yes !&lt;/p&gt;

&lt;p&gt;But if you are fine with opening Git CMD or Bash by using your mouse and everytime you want to open a new window ? Then not really.&lt;/p&gt;

&lt;h3&gt;
  
  
  Manually adding Git to PATH
&lt;/h3&gt;

&lt;p&gt;When you move your USB to another Windows PC, you can repeat the steps above by launching &lt;code&gt;git-cmd.exe&lt;/code&gt;. But by default, &lt;strong&gt;Windows won’t recognize &lt;code&gt;git&lt;/code&gt; on the command line unless you add it to the PATH&lt;/strong&gt;. Here’s how to test and fix that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On the new PC, plug in your USB and open &lt;strong&gt;File Explorer&lt;/strong&gt;. Note the drive letter assigned (e.g. &lt;code&gt;F:&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;Open a standard Windows Command Prompt (not Git CMD). In it, type:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;   &lt;span class="kd"&gt;git&lt;/span&gt; &lt;span class="na"&gt;--version
   &lt;/span&gt;&lt;span class="nb"&gt;where&lt;/span&gt; &lt;span class="kd"&gt;git&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If Git is not already installed on the PC, you’ll get an error or no result. If Git &lt;em&gt;is&lt;/em&gt; installed system-wide, &lt;code&gt;where git&lt;/code&gt; might show something like &lt;code&gt;C:\Program Files\Git\cmd\git.exe&lt;/code&gt;. Either way, the portable Git isn’t yet in the PATH.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Temporarily add the USB Git to the PATH by running (replace &lt;code&gt;F:&lt;/code&gt; with your actual drive letter):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;   &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="kd"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kd"&gt;F&lt;/span&gt;:\PortableGit\cmd&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="nv"&gt;%PATH%&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure there are no spaces around the &lt;code&gt;=&lt;/code&gt;. This prepends your USB’s Git folder to the PATH for this Command Prompt session.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now type again:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;   &lt;span class="nb"&gt;where&lt;/span&gt; &lt;span class="kd"&gt;git&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see two entries: &lt;code&gt;F:\PortableGit\cmd\git.exe&lt;/code&gt; &lt;strong&gt;above&lt;/strong&gt; any &lt;code&gt;C:\Program Files\Git\cmd\git.exe&lt;/code&gt;. The fact that the F: path comes first means your portable Git will be used in this session.  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; Keep your portable Git folder organized. If you want to use it on multiple drives, note the drive letter might change (E:, F:, etc.), so always check and adjust the path accordingly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;Test Git on this CMD prompt:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;   &lt;span class="kd"&gt;git&lt;/span&gt; &lt;span class="na"&gt;--version
   &lt;/span&gt;&lt;span class="kd"&gt;git&lt;/span&gt; &lt;span class="kd"&gt;init&lt;/span&gt;
   &lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="kd"&gt;usb&lt;/span&gt;&lt;span class="na"&gt;-test
   &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="kd"&gt;usb&lt;/span&gt;&lt;span class="na"&gt;-test
   &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="kd"&gt;This&lt;/span&gt; &lt;span class="kd"&gt;is&lt;/span&gt; &lt;span class="kd"&gt;an&lt;/span&gt; &lt;span class="kd"&gt;example&lt;/span&gt; &lt;span class="kd"&gt;text&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kd"&gt;example&lt;/span&gt;.txt
   &lt;span class="kd"&gt;git&lt;/span&gt; &lt;span class="kd"&gt;add&lt;/span&gt; &lt;span class="kd"&gt;example&lt;/span&gt;.txt
   &lt;span class="kd"&gt;git&lt;/span&gt; &lt;span class="kd"&gt;status&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should again see Git initialized successfully and the new file listed by &lt;code&gt;git status&lt;/code&gt;. All commands are being run by the portable Git from your USB.  &lt;/p&gt;

&lt;p&gt;Remember, the &lt;code&gt;set PATH=...&lt;/code&gt; command only lasts for that Command Prompt window. If you open a new Command Prompt, you would need to repeat the &lt;code&gt;set PATH&lt;/code&gt; step (or use &lt;code&gt;setx&lt;/code&gt; to make it permanent, which requires admin rights). For occasional use, it’s fine to just do it manually each time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F0t6h77jp6e4mi3cia1xp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F0t6h77jp6e4mi3cia1xp.png" alt=" " width="720" height="796"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; If you ever need to “uninstall” portable Git from a PC, simply delete the extracted Git folder or remove it from the PATH (since it didn’t install, there’s no uninstaller)&lt;/p&gt;

&lt;p&gt;&lt;u&gt;You should now be able to use Git as a Portable Software.&lt;/u&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>portable</category>
      <category>productivity</category>
      <category>custom</category>
    </item>
  </channel>
</rss>
