<?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: vandna kapoor</title>
    <description>The latest articles on DEV Community by vandna kapoor (@vandnakapoor19).</description>
    <link>https://dev.to/vandnakapoor19</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%2F398312%2F78e73ab9-4249-492b-b0cc-f47247bcf441.jpg</url>
      <title>DEV Community: vandna kapoor</title>
      <link>https://dev.to/vandnakapoor19</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vandnakapoor19"/>
    <language>en</language>
    <item>
      <title>JavaScript’s Role in Web Development: A Comprehensive Introduction</title>
      <dc:creator>vandna kapoor</dc:creator>
      <pubDate>Sun, 27 Jul 2025 14:55:29 +0000</pubDate>
      <link>https://dev.to/vandnakapoor19/javascripts-role-in-web-development-a-comprehensive-introduction-30ja</link>
      <guid>https://dev.to/vandnakapoor19/javascripts-role-in-web-development-a-comprehensive-introduction-30ja</guid>
      <description>&lt;p&gt;&lt;strong&gt;JavaScript (JS)&lt;/strong&gt; Possibly the most popular programming language in the world, JavaScript underpins the web by enabling dynamic and interactive pages. But its flexibility and versatility are available on a wide range of platforms beyond the browser, from servers and smartphones to embedded systems, and it has emerged as a way of creating rich, engaging applications on all those devices. Annual updates to the language introduce new features and improvements to the functionality, readability and performance of JavaScript. These updates also increase developer productivity, ensuring it’s a language that is fast to write and easy to get started with, keeping it relevant for increasingly challenging scenarios.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Brief History &amp;amp; Origins&lt;/strong&gt;&lt;br&gt;
JavaScript was created by Brendan Eich in just 10 days for the Netscape browser and was originally called Mocha, then LiveScript. Despite its quick start, it was inspired by languages like Scheme and Java, making it powerful and flexible. It became an official standard (ECMAScript) in 1997.&lt;/p&gt;

&lt;p&gt;Though updates slowed after ES5 in 2009, a strong community kept it evolving through libraries and frameworks. In 2015, ES6 brought major improvements and kicked off yearly updates that continue to enhance the language.&lt;/p&gt;

&lt;p&gt;JavaScript also expanded beyond the browser. With the release of Node.js in 2009, it became a full-stack language, running on servers and powering everything from web apps to backend systems.&lt;/p&gt;

&lt;p&gt;Standardized as ECMAScript in 1997, evolving through versions ES5, ES6 (2015), and annual updates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where JavaScript Runs&lt;/strong&gt;&lt;br&gt;
Client-side: Every major browser includes a JS engine (V8, SpiderMonkey, JavaScriptCore).&lt;/p&gt;

&lt;p&gt;Server-side: With Node.js, JavaScript runs outside the browser, enabling full-stack development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features That Drive Popularity&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Versatile and ubiquitous:&lt;/strong&gt; Works across all major platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-paradigm:&lt;/strong&gt; Supports procedural, object-oriented, and functional programming.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rich ecosystem:&lt;/strong&gt; npm, React, Angular, Vue, and more.&lt;/p&gt;

&lt;p&gt;It also has powerful tooling support, especially when used with TypeScript, a popular superset of JavaScript that adds static typing and better developer tooling. TypeScript enhances JavaScript with type safety, making it easier to manage large codebases and catch errors early during development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What You Can Build with JavaScript&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Interactive web apps&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Single-page applications&lt;/strong&gt; using React js&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;APIs and backends&lt;/strong&gt; using Node.js&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile and desktop apps&lt;/strong&gt; using React Native and Electron&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Games, AI tools, and browser extensions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;With the combination of JavaScript, React.js for the UI layer, and TypeScript for type safety, developers can create high-performance, scalable apps for virtually any platform.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Community &amp;amp; Ecosystem&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Largest package ecosystem via &lt;strong&gt;npm&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Strong community support, frequent updates&lt;/li&gt;
&lt;li&gt;Supported by major companies like Google (Angular), Facebook (React), and Microsoft (TypeScript + VS Code)&lt;/li&gt;
&lt;li&gt;Modern editors and dev tools (like VS Code) are optimized for JavaScript and its ecosystem, including frameworks like React and languages like TypeScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Comparison with Other Languages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;JavaScript vs Java&lt;/strong&gt;: Java is statically typed and compiled; JS is interpreted and dynamic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JavaScript vs Python&lt;/strong&gt;: Both are beginner-friendly, but JS dominates the browser space.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JavaScript + TypeScript&lt;/strong&gt;: Many developers now prefer combining JS with TypeScript to get the best of both worlds — flexibility and structure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JavaScript + React&lt;/strong&gt;: Developers can build highly responsive UIs with less code and better state control compared to older methods.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Looking Ahead&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With growing support for &lt;strong&gt;WebAssembly&lt;/strong&gt;, serverless computing, and modern runtimes like &lt;strong&gt;Deno&lt;/strong&gt; and &lt;strong&gt;Bun&lt;/strong&gt;, JavaScript (along with tools like React and TypeScript) continues to shape the future of software development across browsers, servers, and beyond.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript remains the &lt;strong&gt;backbone of the web&lt;/strong&gt;, and with modern enhancements like React.js for UI and TypeScript for structure, the ecosystem is more powerful and developer-friendly than ever. Whether you’re just starting or building enterprise-grade applications, JavaScript is a must-learn skill for today’s tech world.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>learning</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Difference between HTML and React event handling</title>
      <dc:creator>vandna kapoor</dc:creator>
      <pubDate>Sun, 23 Jan 2022 04:20:37 +0000</pubDate>
      <link>https://dev.to/vandnakapoor19/difference-between-html-and-react-event-handling-59bh</link>
      <guid>https://dev.to/vandnakapoor19/difference-between-html-and-react-event-handling-59bh</guid>
      <description>&lt;p&gt;In terms of syntax and standards, HTML and React handle events differently because React is built on the notion of a virtual DOM, whereas HTML always has access to the Real DOM.&lt;/p&gt;

&lt;h3&gt;
  
  
  The following are the significant distinctions we will discuss:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In HTML, event names are written in lowercase, however in React, they are written in camelCase.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In HTML, we may avoid default behavior by returning &lt;code&gt;false&lt;/code&gt;, but in React, we must call &lt;code&gt;preventDefault()&lt;/code&gt; explicitly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In HTML, the function is called by inserting "()" to the function name. If we don't want to utilize this way, we may use addEventLisener to provide events and listeners, however in React, we require the method name without the "()" appended.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  1) In HTML, event names are written in lowercase,
&lt;/h5&gt;

&lt;p&gt;Let us take a example where we would like to invoke click event on the button:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;button onclick='handleEvent()'&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  however in React, they are written in camelCase.
&lt;/h5&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;button onClick={handleEvent}&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2) In HTML, we may avoid default behavior by returning &lt;code&gt;false&lt;/code&gt;, but in React, we must call &lt;code&gt;preventDefault()&lt;/code&gt; explicitly
&lt;/h4&gt;

&lt;p&gt;Let's start by making a simple form and giving the input text a name. After submitting the form, we must call the 'onsubmit' event, and the form must not be refreshed.&lt;/p&gt;

&lt;h5&gt;
  
  
  HTML Example
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form onsubmit="console.log('You clicked submit.'); return false"&amp;gt;
   &amp;lt;input  type="text" name="name" /&amp;gt;
   &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;

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

&lt;/div&gt;



&lt;h5&gt;
  
  
  React Example
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Form() {
  function handleSubmit(e) {
    e.preventDefault();
    console.log('You clicked submit.');
  }
 return (
   &amp;lt;form onsubmit="{handleSubmit}"&amp;gt;
    &amp;lt;input  type="text" name="name" /&amp;gt;
    &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
   &amp;lt;/form&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3) In HTML, the function is called by inserting "()" to the function name. If we don't want to utilize this way, we may use addEventLisener to provide events and listeners, however in React, we require the method name without the "()" appended
&lt;/h4&gt;

&lt;h5&gt;
  
  
  HTML Example
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;button onclick='activateLasers()'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  React Example
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button onClick={activateLasers}&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>html</category>
      <category>react</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>NPM vs. YARN: Basic Commands</title>
      <dc:creator>vandna kapoor</dc:creator>
      <pubDate>Wed, 24 Nov 2021 21:16:05 +0000</pubDate>
      <link>https://dev.to/vandnakapoor19/npm-vs-yarn-basic-commands-3bl6</link>
      <guid>https://dev.to/vandnakapoor19/npm-vs-yarn-basic-commands-3bl6</guid>
      <description>&lt;p&gt;Here is a quick reference guide for basic commands that we can use when dealing with Node and requiring the use of NPM or YARN.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;h5&gt;
  
  
  Install dependencies from package.json:
&lt;/h5&gt;



&lt;p&gt;&lt;code&gt;npm install == yarn&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h5&gt;
  
  
  Install a package and add to package.json:
&lt;/h5&gt;



&lt;p&gt;&lt;code&gt;npm install package --save == yarn add package&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h5&gt;
  
  
  Install a devDependency to package.json:
&lt;/h5&gt;



&lt;p&gt;&lt;code&gt;npm install package --save-dev == yarn add package --dev&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h5&gt;
  
  
  Remove a dependency from package.json:
&lt;/h5&gt;



&lt;p&gt;&lt;code&gt;npm uninstall package --save == yarn remove package&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h5&gt;
  
  
  Upgrade a package to its latest version:
&lt;/h5&gt;



&lt;p&gt;&lt;code&gt;npm update --save == yarn upgrade&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h5&gt;
  
  
  Install a package globally:
&lt;/h5&gt;



&lt;p&gt;&lt;code&gt;npm install package -g == yarn global add package&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>react</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Understanding the"this” Keyword in JavaScript</title>
      <dc:creator>vandna kapoor</dc:creator>
      <pubDate>Thu, 10 Sep 2020 15:32:20 +0000</pubDate>
      <link>https://dev.to/vandnakapoor19/understanding-the-this-keyword-in-javascript-g6h</link>
      <guid>https://dev.to/vandnakapoor19/understanding-the-this-keyword-in-javascript-g6h</guid>
      <description>&lt;p&gt;The &lt;code&gt;this&lt;/code&gt; keyword is a fundamental concept in JavaScript, and also an incredibly confusing one to both new developers and those who have experience in other programming languages. In JavaScript, &lt;code&gt;this&lt;/code&gt; is a reference to an &lt;code&gt;object&lt;/code&gt;. The object that this refers to can vary, &lt;code&gt;implicitly&lt;/code&gt; based on whether it is global, on an object, or in a constructor, and can also vary &lt;code&gt;explicitly&lt;/code&gt; based on usage of the Function prototype methods bind, call, and apply.&lt;/p&gt;

&lt;h4&gt;
  
  
  Here we will cover
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; in Global Environment&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; inside Functions&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; in Methods&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; With the Call and Apply Methods&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; With the Bind Method&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; With the Fat-Arrow Function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1) &lt;code&gt;this&lt;/code&gt; in Global Environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By default, the execution context for any execution is global, which means if we are running any simple function, then &lt;code&gt;this&lt;/code&gt; refers to a &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Global_object" rel="noopener noreferrer"&gt;global object&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"As we know &lt;code&gt;window&lt;/code&gt; is the global object in the case of the &lt;code&gt;browser&lt;/code&gt;, However, if we are using  &lt;code&gt;NodeJS&lt;/code&gt;, then a special object &lt;code&gt;global&lt;/code&gt; is the global object."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;On Browser&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;foo&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Simple function call&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="o"&gt;===&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;//prints true on console&lt;/span&gt;
&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%2Fi%2Fsraanqhb9d1fmkb9v2v3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsraanqhb9d1fmkb9v2v3.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a function is invoked with the &lt;code&gt;new keyword&lt;/code&gt;, then the function is known as a constructor function and returns a new instance. In such cases, the value of this refers to a newly created instance.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;foo&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Simple function call&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="o"&gt;===&lt;/span&gt; &lt;span class="nb"&gt;window&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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;//prints false on console&lt;/span&gt;

&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%2Fi%2F9ha0038wdowu0wjefvzx.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9ha0038wdowu0wjefvzx.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Using Node&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; this === global
true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;2) &lt;code&gt;this&lt;/code&gt; inside Functions&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Hero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;heroName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;realName&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;realName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;realName&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;heroName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;heroName&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;superman&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Hero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Superman&lt;/span&gt;&lt;span class="dl"&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;Clark Kent&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;superman&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&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%2Fi%2Fo9tnfmoy11unbwhxin1g.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fo9tnfmoy11unbwhxin1g.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that this function is not written in strict mode. Running this code in the &lt;strong&gt;node&lt;/strong&gt; will not get us the value of &lt;code&gt;Superman&lt;/code&gt; and &lt;code&gt;Clark Kent&lt;/code&gt; as we expected, but it will instead just give us an &lt;strong&gt;undefined&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The reason behind this is that since the function is not written in &lt;code&gt;strict mode&lt;/code&gt;*, this refers to the global object.&lt;/p&gt;

&lt;p&gt;If we run this code in &lt;code&gt;strict mode&lt;/code&gt;, we will get an error because JavaScript does not allow us to assign properties &lt;code&gt;realName&lt;/code&gt; and &lt;code&gt;"heroName&lt;/code&gt; to undefined. This is a good thing because it prevents us from creating global variables.&lt;/p&gt;

&lt;p&gt;Lastly, writing the function’s name in uppercase means that we need to call it as a constructor using the new operator. Replace the last two lines of the above code snippet with this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Hero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;heroName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;realName&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;realName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;realName&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;heroName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;heroName&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;superman&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;Hero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Superman&lt;/span&gt;&lt;span class="dl"&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;Clark Kent&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;superman&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&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%2Fi%2Fwj40o5cufy17hxshwrmn.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwj40o5cufy17hxshwrmn.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3) &lt;code&gt;this&lt;/code&gt; in Methods&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hero&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;heroName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Batman&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;dialogue&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`I am &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;heroName&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="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dialogue&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&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%2Fi%2F3w7xg1qrkjxrpsq852dq.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3w7xg1qrkjxrpsq852dq.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;4) &lt;code&gt;this&lt;/code&gt; With the Call and Apply Methods&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;call and apply are very similar-they invoke a function with a specified this context and optional arguments.&lt;/p&gt;

&lt;p&gt;The only &lt;code&gt;difference between call and apply&lt;/code&gt; is that call requires the arguments to be passed in one-by-one, and apply takes the arguments as an array.&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;book&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Brave New World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Aldous Huxley&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; was written by &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;author&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="nf"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&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%2Fi%2Fwvmzpkvtv8emiby2yjta.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwvmzpkvtv8emiby2yjta.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since summary and book have no connection, invoking summary by itself will only print &lt;code&gt;undefined&lt;/code&gt;, as its looking for those properties on the global object.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;book&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Brave New World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Aldous Huxley&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;abc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;author&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;test&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;summary&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; was written by &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;author&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;summary&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;book&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// or:&lt;/span&gt;
&lt;span class="nx"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&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%2Fi%2F7kgmi3wtcqce669gj0ou.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7kgmi3wtcqce669gj0ou.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5) &lt;code&gt;this&lt;/code&gt; With the Bind Method&lt;/strong&gt;&lt;br&gt;
The bind method returns a new method with this referring to the first argument passed. We’re going to use the above example to explain the bind method.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ln&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;first_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fn&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;last_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ln&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;displayName&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="s2"&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;first_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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;last_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="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="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;John&lt;/span&gt;&lt;span class="dl"&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;Reed&lt;/span&gt;&lt;span class="dl"&gt;"&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;displayName&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Prints Name: John Reed&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person2&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;Paul&lt;/span&gt;&lt;span class="dl"&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;Adams&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;person2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Prints Name: Paul Adams&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person2Display&lt;/span&gt; &lt;span class="o"&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;displayName&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="nx"&gt;person2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Creates new function with value of “this” equals to person2 object&lt;/span&gt;
&lt;span class="nf"&gt;person2Display&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Prints Name: Paul Adams&lt;/span&gt;
&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%2Fi%2Flckk1cvccpqn5nqwzajp.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flckk1cvccpqn5nqwzajp.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6) &lt;code&gt;this&lt;/code&gt; With the Fat-Arrow Function&lt;/strong&gt;&lt;br&gt;
unlike Regular functions, the arrow function does not have their own &lt;code&gt;this&lt;/code&gt; keyword.&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;The value of this inside an arrow function remains the same throughout the lifecycle of the function and is always bound to the value of this in the closest non-arrow parent function.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff93aha2je1ybp8nxzcx3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff93aha2je1ybp8nxzcx3.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>react</category>
    </item>
    <item>
      <title>The Difference Between Regular Functions and Arrow Functions</title>
      <dc:creator>vandna kapoor</dc:creator>
      <pubDate>Wed, 12 Aug 2020 02:28:12 +0000</pubDate>
      <link>https://dev.to/vandnakapoor19/the-difference-between-regular-functions-and-arrow-functions-j7d</link>
      <guid>https://dev.to/vandnakapoor19/the-difference-between-regular-functions-and-arrow-functions-j7d</guid>
      <description>&lt;p&gt;Arrow function — also called fat arrow function — is a new feature introduced in ES6 that is a more concise syntax for a writing function expression.&lt;/p&gt;

&lt;h4&gt;
  
  
  Following are the main differences:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Syntax&lt;/li&gt;
&lt;li&gt;Arguments binding&lt;/li&gt;
&lt;li&gt;Use of this keyword&lt;/li&gt;
&lt;li&gt;Using a new keyword&lt;/li&gt;
&lt;li&gt;No duplicate named parameters&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  1) Syntax:
&lt;/h4&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;A developer can get the same result as regular functions by writing a few lines of code using arrow functions.&lt;/p&gt;

&lt;p&gt;Curly brackets are not required if only one expression is present.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let add = (x, y) =&amp;gt; x + y;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If there’s only one argument, then the parentheses are not required either:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let squareNum = x =&amp;gt; x * x;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  2) Arguments binding
&lt;/h4&gt;

&lt;p&gt;Arrow functions do not have arguments binding.&lt;/p&gt;
&lt;h6&gt;
  
  
  Regular Function
&lt;/h6&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Object with Regular function.&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;getData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// Regular function&lt;/span&gt;
    &lt;span class="na"&gt;showArg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arguments&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;getData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;showArg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// output {0:1,1:2,2:3}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h6&gt;
  
  
  Output
&lt;/h6&gt;

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


&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Object with Arrow function.&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;getData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// Arrow function&lt;/span&gt;
    &lt;span class="na"&gt;showArg&lt;/span&gt;&lt;span class="p"&gt;:()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;getData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;showArg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Uncaught ReferenceError: arguments is not defined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h6&gt;
  
  
  Output
&lt;/h6&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X9AhaJEm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5o050o99h1zr0434neyo.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X9AhaJEm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5o050o99h1zr0434neyo.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  3) Use of this keyword
&lt;/h4&gt;

&lt;p&gt;unlike Regular functions, arrow function does not have their own "this" keyword.&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;The value of this inside an arrow function remains the same throughout the lifecycle of the function and is always bound to the value of this in the closest non-arrow parent function.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

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

&lt;h4&gt;
  
  
  4) Using a new keyword
&lt;/h4&gt;

&lt;p&gt;Regular functions created using function declarations or expressions are constructible and callable. Regular functions are constructible; they can be called using the new keyword.&lt;/p&gt;

&lt;p&gt;However, the arrow functions are only callable and not constructible, i.e., arrow functions can never be used as constructor functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Regular function&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IErZqbIJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6fe0l4byw1pmm3vzwg21.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IErZqbIJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6fe0l4byw1pmm3vzwg21.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arrow function&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let add = (x, y) =&amp;gt; console.log(x + y);
new add(2,3);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



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

&lt;h4&gt;
  
  
  5) No duplicate named parameters
&lt;/h4&gt;

&lt;p&gt;Arrow functions can never have duplicate named parameters, whether in strict or non-strict mode.&lt;/p&gt;

&lt;p&gt;However, We can use duplicate named parameters for regular function in non-strict mode.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>node</category>
    </item>
  </channel>
</rss>
