<?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: Tarun Nagpal</title>
    <description>The latest articles on DEV Community by Tarun Nagpal (@tarun_geek).</description>
    <link>https://dev.to/tarun_geek</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%2F142628%2Fc0af9f1b-6219-4f62-9025-3ba29d317751.jpeg</url>
      <title>DEV Community: Tarun Nagpal</title>
      <link>https://dev.to/tarun_geek</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tarun_geek"/>
    <language>en</language>
    <item>
      <title>Open ai react</title>
      <dc:creator>Tarun Nagpal</dc:creator>
      <pubDate>Sun, 23 Feb 2025 17:33:16 +0000</pubDate>
      <link>https://dev.to/tarun_geek/open-ai-react-1apn</link>
      <guid>https://dev.to/tarun_geek/open-ai-react-1apn</guid>
      <description></description>
      <category>openai</category>
      <category>react</category>
    </item>
    <item>
      <title>React open ai</title>
      <dc:creator>Tarun Nagpal</dc:creator>
      <pubDate>Sun, 23 Feb 2025 17:32:03 +0000</pubDate>
      <link>https://dev.to/tarun_geek/react-open-ai-36mf</link>
      <guid>https://dev.to/tarun_geek/react-open-ai-36mf</guid>
      <description></description>
      <category>react</category>
      <category>openai</category>
    </item>
    <item>
      <title>Discussion: What is a good Vulnerability Scanner for my JavaScript Project</title>
      <dc:creator>Tarun Nagpal</dc:creator>
      <pubDate>Thu, 29 Apr 2021 15:03:35 +0000</pubDate>
      <link>https://dev.to/tarun_geek/discussion-what-is-a-good-vulnerability-scanner-for-my-javascript-project-4ck1</link>
      <guid>https://dev.to/tarun_geek/discussion-what-is-a-good-vulnerability-scanner-for-my-javascript-project-4ck1</guid>
      <description></description>
      <category>javascript</category>
      <category>javascriptdevelopers</category>
      <category>programming</category>
      <category>npm</category>
    </item>
    <item>
      <title>How to create an NPM Package in 5 minutes</title>
      <dc:creator>Tarun Nagpal</dc:creator>
      <pubDate>Sat, 27 Feb 2021 19:04:46 +0000</pubDate>
      <link>https://dev.to/tarun_geek/how-to-create-an-npm-package-in-5-minutes-5ejn</link>
      <guid>https://dev.to/tarun_geek/how-to-create-an-npm-package-in-5-minutes-5ejn</guid>
      <description>&lt;p&gt;What is NPM &lt;br&gt;
It is a package manager for the JavaScript programming language. This is the world's largest Software Registry.&lt;/p&gt;

&lt;p&gt;Step 1 - Create an npm project &lt;br&gt;
 1.1 Create a folder named "my_demo_calculator"&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mkdir my_demo_calculator&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;1.2 Create an npm project&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm init -y&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;It will turn your project folder into an npm package &lt;/p&gt;

&lt;p&gt;1.3 Create a file named "index.js" and add the following code to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add(x,y){
    return x+y;
}
function sub(x,y){
    return x-y;
}
function mul(x,y){
    return x*y;
}
function divide(x,y){
    return x/y;
}

module.exports = {add,sub,mul,divide}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;1.3 (Optional) Create a README.md file and add it to the folder &lt;/p&gt;

&lt;p&gt;1.4 Login into the NPM Registry. You need to create an account on npmjs.com and use the same here&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm login&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;1.5 Publish the Package with the following command&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm publish&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;That's It!&lt;/p&gt;

&lt;p&gt;You can see my sample package on the links below &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/demo_npm_package_devtalks" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/demo_npm_package_devtalks&lt;/a&gt; &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>npm</category>
    </item>
    <item>
      <title>Prototypal Inheritance In JavaScript</title>
      <dc:creator>Tarun Nagpal</dc:creator>
      <pubDate>Fri, 11 Sep 2020 09:30:52 +0000</pubDate>
      <link>https://dev.to/tarun_geek/inheritance-in-javasript-40lj</link>
      <guid>https://dev.to/tarun_geek/inheritance-in-javasript-40lj</guid>
      <description>&lt;p&gt;I have recently gone through some of the roots in JavaScript. It always fruitful when you look back to the basics of any Language. &lt;/p&gt;

&lt;p&gt;There were a couple of questions in my Mind like &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;What is Prototype in JS?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is Prototypal Inhertictane? How it is different from OOPS Inhertictane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How does Class work in JS?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In order to get all the answers, I created a small program on both the JS versions (Es5 and ES6).&lt;/p&gt;

&lt;p&gt;Doing a practical will give you more understanding than reading and watching videos. &lt;/p&gt;

&lt;p&gt;So let's get started.&lt;/p&gt;

&lt;p&gt;Inheritance in Older Version &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create a function(Tile) which will act as a base class.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 2 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create a function(PushableTile) which will act as a Child class.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 3 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Assign the Prototype of Base class to Child class prototype. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 4 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Add methods to the child class, we will use it to access the Parent Class. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 5 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create an Object from Child Class&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;// Base Class &lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Tile&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;type&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;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;x&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;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;y&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;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="c1"&gt;// Child Class&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;PushableTile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;Tile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;call&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;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Inheritence &lt;/span&gt;
&lt;span class="nx"&gt;PushableTile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Tile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Add Methods to the child class &lt;/span&gt;
&lt;span class="nx"&gt;PushableTile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&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="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&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;x&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;x&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;y&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;object&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;PushableTile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inheritance in New JS Version&lt;/p&gt;

&lt;p&gt;Step 1 &lt;/p&gt;

&lt;p&gt;Create a base class (Tile) with a constructor.&lt;/p&gt;

&lt;p&gt;Step 2 &lt;/p&gt;

&lt;p&gt;Create a Child class with the constructor.&lt;/p&gt;

&lt;p&gt;Step 3 &lt;/p&gt;

&lt;p&gt;Add Super to the Base Class. It will help to pass the same parameters to the Parent class. &lt;/p&gt;

&lt;p&gt;Basically, it is doing the same thing as the below code is doing.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;javascript Tile.call(this, x, y, type);&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Step 4 &lt;/p&gt;

&lt;p&gt;Add methods to the Child class. &lt;/p&gt;

&lt;p&gt;Step 5 &lt;/p&gt;

&lt;p&gt;Create an Object from Child Class&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;// Base Class &lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Tile&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;type&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;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;x&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;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;y&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;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;type&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CONSTRUCTOR&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;// extends is same as PushableTile.prototype = Object.create(Tile.prototype);&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;PushableTile&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Tile&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Tile.call(this, x, y, type);&lt;/span&gt;
      &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&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;x&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;x&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;y&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;y&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;object&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;PushableTile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>inheritance</category>
      <category>prototypeinjavascript</category>
    </item>
  </channel>
</rss>
