<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amandeep Kochhar on Medium]]></title>
        <description><![CDATA[Stories by Amandeep Kochhar on Medium]]></description>
        <link>https://medium.com/@amandeepkochhar?source=rss-792a6d14d963------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1bsrFl7tv5q1jL7IpJ98bg.jpeg</url>
            <title>Stories by Amandeep Kochhar on Medium</title>
            <link>https://medium.com/@amandeepkochhar?source=rss-792a6d14d963------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 03:44:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amandeepkochhar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[React useState Lazy Initialization: The Performance Secret Nobody Teaches]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://amandeepkochhar.medium.com/react-usestate-lazy-initialization-the-performance-secret-nobody-teaches-f917c3c67792?source=rss-792a6d14d963------2"><img src="https://cdn-images-1.medium.com/max/2600/1*gIBqXvcF7AvIRLzRqJHd5w.png" width="2880"></a></p><p class="medium-feed-snippet">Check out the video for practical example: https://youtu.be/QM_DzAbAsr0</p><p class="medium-feed-link"><a href="https://amandeepkochhar.medium.com/react-usestate-lazy-initialization-the-performance-secret-nobody-teaches-f917c3c67792?source=rss-792a6d14d963------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://amandeepkochhar.medium.com/react-usestate-lazy-initialization-the-performance-secret-nobody-teaches-f917c3c67792?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/f917c3c67792</guid>
            <category><![CDATA[optimisation]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[usestate]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Sun, 02 Nov 2025 05:49:43 GMT</pubDate>
            <atom:updated>2025-11-02T05:50:27.515Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Goodbye dotenv  — Native .env Support in Node.js 20+]]></title>
            <link>https://amandeepkochhar.medium.com/goodbye-dotenv-native-env-support-in-node-js-20-9be39ba11a09?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/9be39ba11a09</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[dotenv]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Sun, 15 Jun 2025 06:10:53 GMT</pubDate>
            <atom:updated>2025-06-15T06:50:55.740Z</atom:updated>
            <content:encoded><![CDATA[<h3>Goodbye dotenv 👋 — Native .env Support in Node.js 20+</h3><p>Until now, whenever we wanted to load environment variables from a .env file in a Node.js project, the popular dotenv package was the go-to solution. It&#39;s simple, reliable, and widely used across thousands of projects.</p><p>But with the release of <strong>Node.js 20</strong>, that changes forever.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QvR0U7-xJOlfCYJC" /></figure><h3>The New Native Way to Load .env Files</h3><p>Node.js 20 introduces <strong>native support</strong> for loading environment variables directly from .env files — no external packages required.</p><p>All you need to do is run your Node.js app with this flag:</p><pre>node --env-file=.env index.js</pre><p>That’s it. No more installing dotenv, no more extra imports.</p><h3>Why This Matters?</h3><p><strong>One less dependency</strong> — your project becomes cleaner.<br><strong>Faster startup</strong> — no need for runtime config loading via code.<br><strong>Built-in, maintained by Node.js</strong> — no reliance on third-party packages.<br><strong>Simpler environment handling for small apps, CLIs, scripts.</strong></p><h3>But There’s a Catch…</h3><p>If you try this on <strong>Node.js 18 or below</strong>, it won’t work.</p><p>That’s because this feature was introduced in <strong>Node.js 20</strong>, so projects running older versions still need the good old dotenv package (or another solution).</p><h3>Quick Example:</h3><pre># Node.js 20+<br>node --env-file=.env index.js</pre><pre>// index.js<br>console.log(process.env.MY_SECRET);</pre><h3>Watch It In Action 🎥</h3><p>I’ve covered this in detail with a version-by-version demo on my YouTube channel.<br> 👉 <strong>Watch the video here:</strong> <a href="https://youtube.com/shorts/AQGAClfzl9o">https://youtube.com/shorts/AQGAClfzl9o</a></p><h3>Wrapping Up</h3><p>Node.js 20 gives you a reason to ditch dotenv for good, at least for new projects or where version upgrades are possible.</p><p>If you found this useful, drop a comment and share how you manage environment variables in your Node.js apps. 👇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9be39ba11a09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is AI Stealing Your Creative Soul?]]></title>
            <link>https://amandeepkochhar.medium.com/is-ai-stealing-your-creative-soul-19f29c57e043?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/19f29c57e043</guid>
            <category><![CDATA[this-happened-to-me]]></category>
            <category><![CDATA[world]]></category>
            <category><![CDATA[thoughts]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Fri, 13 Jun 2025 17:57:34 GMT</pubDate>
            <atom:updated>2025-06-13T17:57:34.096Z</atom:updated>
            <content:encoded><![CDATA[<p>There’s a strange moment that has been happening lately.</p><p>I sit down to write, and instead of staring into the familiar discomfort of a blank page, I open a chat window. I type a prompt. In seconds, the ideas are flowing. It’s smooth. Efficient. Helpful, even beautiful sometimes.</p><p>But then comes a pause — subtle, quiet.<br>A tiny voice in me asks, <strong><em>Did I even show up for this?</em></strong></p><h3>The Slow Unraveling</h3><p>It didn’t happen all at once. That’s the tricky part.</p><p>I started using AI the way most of us do: to speed things up. To overcome friction. To fill in the awkward gaps. “Just help me get started,” I told it. “Give me a skeleton. I’ll add the flesh.”</p><p>And I did, for a while.</p><p>But slowly, I noticed something shifting. The work was still good. But it didn’t feel like mine anymore. It was polished, sure — but missing something raw. Something human.<br><strong><em>Something like me.</em></strong></p><h3>The Parts We Used to Keep</h3><p>I miss the fumbling.</p><p>The 45 minutes I’d spend turning over one messy idea until something clicked. The way I’d circle around a sentence because I <em>felt</em> something I couldn’t yet name. The panic of “Is this garbage?” followed by the rush of “No — this is it.”</p><p>That tension — the self-doubt, the weird metaphors, the failed attempts — used to bring me closer to myself.</p><p>Now? It’s easy to bypass it all. Just ask the AI. Get an answer. Move on.<br>But the price of that ease is presence. And presence is the soil where meaning grows.</p><h3>Asking for Less… From Ourselves</h3><p>Lately, I’ve noticed how much more I<em>&#39;ve come to rely</em> on the machine. Not just tasks. But thoughts. Emotions. Even instincts.</p><p>I used to walk over to a teammate and say, “Can you look at this? I’m stuck.”<br>Now, I run it through a model.</p><p>I used to journal through my confusion. Now, I feed it a summary and ask for clarity.</p><p>It’s faster. Cleaner. Safer. But it’s lonelier.</p><p>I didn’t realize how many of those small, clumsy interactions — the questions, the sharing, the vulnerable moments — were actually tiny threads tying me to people, and to myself.</p><p>Now I wonder how many of those threads I’ve quietly cut.</p><h3>The Disappearing Artist</h3><p>I’m scared, a little, of becoming a curator of my own work — someone who oversees the output but no longer touches the clay.</p><p>And I see it happening around me too:</p><ul><li>Designers tweaking AI mockups instead of dreaming on paper.</li><li>Writers editing drafts that sound right but feel hollow.</li><li>Developers pasting code that works but never solving the puzzle.</li></ul><p>A quiet giving up of the parts we once fought for, the parts that used to spark joy.</p><h3>Holding Onto the Spark</h3><p>I’m not anti-AI. God, no.</p><p>Some days, it’s helped me <em>become more myself</em> — clarifying what I value, giving me a running start, reflecting back insights I couldn’t quite form alone.</p><p>But I’ve also caught myself nodding too quickly. Clicking “send” before asking, <em>Is this still me?</em></p><p>So I’ve started building little rituals back in:</p><ul><li>Writing a rough paragraph by hand before I prompt.</li><li>Asking a friend, not just the machine, for feedback.</li><li>Leaving room for doubt, silence, and slow thinking.</li></ul><p>Because the truth is, meaning isn’t efficient.<br>Connection isn’t scalable.<br>And sometimes, feeling lost is the only way to find your voice.</p><h3>A Quiet Check-In</h3><p>Before I finish anything now, I ask myself:</p><ul><li>Does this feel like something <em>only I</em> could say?</li><li>Did I show up for this, or just sign off on it?</li><li>Did it move me?</li></ul><p>If the answer is no — I go back in. I make a mess. I wander.<br>Because I’d rather wrestle with something real than perfect something hollow.</p><h3>Final Thought</h3><p>Maybe we don’t need to fear AI.</p><p>Maybe we just need to stay <em>awake</em> inside it.</p><p>Because the moment we stop showing up — not just physically, but emotionally, soulfully — we lose the part of us that made the work worth doing in the first place.</p><p>So, before you close this tab, take a moment. Ask yourself !</p><p><strong>“What have I started outsourcing… that I used to love?”</strong></p><p>And if the answer stings a little, good.<br>That means there’s still something in you that wants to come back.</p><p>Let it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19f29c57e043" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Dark Side of React Custom Hooks: Unnecessary Re-Renders]]></title>
            <link>https://amandeepkochhar.medium.com/the-dark-side-of-react-custom-hooks-unnecessary-re-renders-8ebd3b9fd439?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ebd3b9fd439</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[react-hooks-for-beginners]]></category>
            <category><![CDATA[hooks-in-react]]></category>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Tue, 01 Apr 2025 02:39:01 GMT</pubDate>
            <atom:updated>2025-04-01T02:39:01.197Z</atom:updated>
            <content:encoded><![CDATA[<p>React custom hooks are a fantastic way to reuse logic across your components. They’re clean, modular, and make your code feel more organized. But there’s a sneaky downside:</p><p><strong>State updates in custom hooks can trigger re-renders in your components — even if you’re not using the values they return.</strong></p><p>Let’s break this down with a simple example, explore why it’s a problem, and learn how to fix it in an easy, practical way.</p><h3>The Problem: A Custom Hook That Bites Back</h3><p>Imagine you’re building a React app and you want to track the window’s width. You decide to create a custom hook called useWindowSize to handle this. Here’s what it might look like:</p><pre>const useWindowSize = () =&gt; {<br>  const [width, setWidth] = useState(window.innerWidth);<br><br>  useEffect(() =&gt; {<br>    const handleResize = () =&gt; setWidth(window.innerWidth);<br>    window.addEventListener(&quot;resize&quot;, handleResize);<br>    return () =&gt; window.removeEventListener(&quot;resize&quot;, handleResize);<br>  }, []);<br><br>  return null; // We’re not even returning the width!<br>};<br><br>const App = () =&gt; {<br>  useWindowSize(); // Just calling the hook<br>  return &lt;p&gt;App Component&lt;/p&gt;;<br>};</pre><p>At first glance, this looks fine. The hook listens for window resize events, updates the width state, and… that’s it. The App component calls useWindowSize() but doesn’t use its return value (which is null anyway). So, no harm done, right?</p><p>Wrong. Here’s the catch: every time you resize the window, the setWidth call updates the state inside useWindowSize. Since App component used the hook, React considers the App dependent on it. <strong>The entire App component re-renders on every resize</strong>, even though it doesn’t care about the width value. That’s a performance hit you didn’t sign up for!</p><h4>Why Does This Happen?</h4><p>In React, when a hook updates its internal state (like calling setWidth), it tells any component using that hook: “Hey, something changed — time to re-render!” This happens regardless of whether the component actually uses the hook’s returned value. It’s just how React’s dependency tracking works. In our example, App component re-renders unnecessarily because it’s “tied” to useWindowSize, even though it doesn’t need the width.</p><p>This might not seem like a big deal in a small app, but imagine App is a complex component with lots of child elements. All that re-rendering could slow things down, making your app feel sluggish.</p><h3>Issues</h3><ul><li><strong>Resizing the window triggers a state update</strong> inside useWindowSize.</li><li>Since App <strong>uses</strong> useWindowSizeIt <strong>re-renders every time the window resizes</strong>, even though it <strong>doesn&#39;t use the width</strong>.</li></ul><h3>The Fix: Swap the Hook for a Component</h3><p>So, how do we stop this madness? <strong>The simplest solution is to ditch the custom hook and move the logic into a dedicated component instead.</strong> Here’s how:</p><pre>const WindowSizeComponent = () =&gt; {<br>  const [width, setWidth] = useState(window.innerWidth);<br><br>  useEffect(() =&gt; {<br>    const handleResize = () =&gt; setWidth(window.innerWidth);<br>    window.addEventListener(&quot;resize&quot;, handleResize);<br>    return () =&gt; window.removeEventListener(&quot;resize&quot;, handleResize);<br>  }, []);<br><br>  return &lt;p&gt;Window width: {width}&lt;/p&gt;;<br>};<br><br>const App = () =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;WindowSizeComponent /&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>Now, the width state and the resize logic live inside WindowSizeComponent. When the window resizes, only WindowSizeComponent re-renders — App component stays untouched. This keeps your app performant because React only updates the part of the UI that actually needs to change.</p><h3>When to Use Hooks vs. Components</h3><p>Custom hooks are awesome when you need reusable logic that components <em>actually use</em> — like fetching data or managing form state. But <strong>if the logic involves state updates that don’t need to be shared or consumed elsewhere (like our window resize example), a component might be the better choice.</strong> It’s all about keeping re-renders under control.</p><h3>Takeaway</h3><p>React custom hooks are powerful, but they come with a dark side:</p><p><strong>State updates can trigger re-renders in unexpected places. If your hook’s return value isn’t being used, those updates might still haunt your app’s performance.</strong> Next time you’re tempted to throw state into a custom hook “just because,” pause and ask: <em>Would a component work better here?</em> Your app — and your users — will thank you for it.</p><blockquote>I’ve been working with React, Node, and TypeScript for the past 5+ years, gaining valuable insights from numerous projects. Now, I want to share everything I’ve learned along the way.</blockquote><blockquote>“This is just a glimpse! I’m currently writing a book <strong>‘You Don’t Know React Yet!’</strong> — Stay tuned for more updates.”<strong><em> 🚀</em></strong></blockquote><p>Want to support me? Consider buy me <a href="http://buymeacoffee.com/amandeepkochhar">a coffee</a>! ☕💙<br> 👉 <a href="https://buymeacoffee.com/amandeepkochhar">buymeacoffee.com/amandeepkochhar</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ebd3b9fd439" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[2025] — Setting Up Tailwind CSS with Vite: A Quick and Easy Guide]]></title>
            <link>https://amandeepkochhar.medium.com/2025-setting-up-tailwind-css-with-vite-a-quick-and-easy-guide-86f15335f401?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/86f15335f401</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[vitejs]]></category>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Mon, 31 Mar 2025 17:20:12 GMT</pubDate>
            <atom:updated>2025-04-01T02:34:04.717Z</atom:updated>
            <content:encoded><![CDATA[<h3>[2025] — Setting Up Tailwind CSS with Vite: A Quick and Easy Guide</h3><p>Tailwind CSS and Vite are excellent for building modern, fast, and highly customizable web applications. Tailwind provides utility-first styling, while Vite offers a lightning-fast development experience with instant hot module replacement (HMR).</p><p>In this article, we’ll walk through setting up Tailwind CSS with Vite step by step.</p><h4>Step 1: Set Up a Vite Project</h4><p>First, install Vite globally if you haven’t already:</p><pre>npm install -g vite</pre><p>Now, create a new Vite project by running:</p><pre>npm create vite@latest</pre><p>The following prompt will appear:</p><figure><img alt="Project name" src="https://cdn-images-1.medium.com/max/652/1*JQxofAERypmMDWL2YT32bw.png" /></figure><p>Give a project name, For example i have given vite-starter as the project name. In case of if you have already created a folder you can give dot (.) to tell vite to put boilerplate code in the same folder. Like i have already created vite-starter folder. I will name dot(.) as the project name.</p><p>Then it will prompt you to Select a framework. Choose a framework that you want to work with. I will choose React as i am initialising the React Application.</p><figure><img alt="Choose framework" src="https://cdn-images-1.medium.com/max/617/1*oMNhJ-XayukySKg2PGBgsQ.png" /></figure><p>Finally, in case of React, it will ask to choose a variant, Here i will go for the Typescript as the variant and hit Enter.</p><figure><img alt="Select variant" src="https://cdn-images-1.medium.com/max/696/1*IjYgxcGJmjXrJjLjrC6QAA.png" /></figure><p>Now the project initialisation is done and will will see the final screen.</p><figure><img alt="Finish" src="https://cdn-images-1.medium.com/max/706/1*KH4OS1dhze5xe_5GSdh2dA.png" /></figure><h4>Step 2: Install Dependencies</h4><p>Once inside your project, install the required dependencies:</p><pre>npm install</pre><p>Now, install Tailwind CSS along with its Vite plugin as dev dependency:</p><pre>npm install --save-dev tailwindcss @tailwindcss/vite</pre><h4>Step 3: Configure Vite to Use Tailwind</h4><p>To integrate Tailwind with Vite, modify the vite.config.ts file (or create one if it doesn’t exist):</p><pre>import { defineConfig } from &quot;vite&quot;;<br>import react from &quot;@vitejs/plugin-react&quot;;<br>import tailwindcss from &quot;@tailwindcss/vite&quot;;<br><br>export default defineConfig({<br>  plugins: [tailwindcss(), react()],<br>});</pre><h4>Step 4: Import Tailwind in Your Styles</h4><p>Create or update index.css (or global.css) and import Tailwind’s base styles:</p><pre>@import &quot;tailwindcss&quot;;</pre><h4>Step 5: Start Your Development Server</h4><p>Run the following command to start the Vite development server:</p><pre>npm run dev</pre><p>Now, open your browser at the given local URL, and you’re ready to use Tailwind with Vite!</p><h4>Additional Notes</h4><ul><li>If Tailwind CSS class autocompletion isn’t working, try reloading the window in VS Code or closing and reopening the project.</li><li>If you want to set the server to run on a specific port, you can add the following to the server object. This will set the server to run on port 3000. You can replace 3000 with any port number you prefer. To open the app immediately in the browser, you can use open: true</li></ul><pre>import { defineConfig } from &quot;vite&quot;;<br>import react from &quot;@vitejs/plugin-react&quot;;<br>import tailwindcss from &quot;@tailwindcss/vite&quot;;<br><br>export default defineConfig({<br>  plugins: [react(), tailwindcss()],<br>  server: {<br>    port: 3000, // replace with your desired port<br>    open: true, // automatically open the app in the browser<br>  },<br>});</pre><ul><li>Use — host flag to enable the app to be accessed and run from other devices on the same network like below:</li></ul><pre>&quot;scripts&quot;: {<br>  &quot;dev&quot;: &quot;vite&quot;,<br>  &quot;online&quot;: &quot;vite --host&quot;, // run using npm run online or yarn online<br>  &quot;build&quot;: &quot;tsc -b &amp;&amp; vite build&quot;,<br>  &quot;lint&quot;: &quot;eslint .&quot;,<br>  &quot;preview&quot;: &quot;vite preview&quot;<br>}</pre><figure><img alt="Expose the app online" src="https://cdn-images-1.medium.com/max/551/1*UeRBml5a9m-VRyWjcX0nlA.png" /></figure><p>Now the application will be accessible from the <a href="http://192.168.29.110:3000/">http://192.168.29.110:3000</a> from all the devices connected to your local network.</p><ul><li>To visualise the bundle size we can use rollup-plugin-visualize plugin. So install it as a dev dependency</li></ul><pre>npm install --save-dev rollup-plugin-visualizer</pre><p>Then import it inside the vite.config.ts Remember to put the file as the last one in the plugins array. Whenever you execute npm run build command, the report will automatically open.</p><pre>import { defineConfig, type PluginOption } from &quot;vite&quot;;<br>import react from &quot;@vitejs/plugin-react&quot;;<br>import tailwindcss from &quot;@tailwindcss/vite&quot;;<br>import { visualizer } from &quot;rollup-plugin-visualizer&quot;;<br><br>export default defineConfig({<br>  plugins: [<br>    react(),<br>    tailwindcss(),<br>    visualizer({<br>      filename: &quot;bundle.html&quot;, // output file name<br>      template: &quot;treemap&quot;, // options: &quot;flamegraph&quot; | &quot;sunburst&quot; | &quot;network&quot; | &quot;treemap&quot; | &quot;raw-data&quot; | &quot;list&quot;<br>      open: true, // Automatically open the report in the browser<br>    }) as PluginOption,<br>  ],<br>  server: {<br>    port: 3000, // replace with your desired port<br>    open: true, // automatically open the app in the browser<br>  },<br>});</pre><p>If you enjoyed this article and found it helpful, give it a clap!</p><blockquote>I’ve been working with React, Node, and TypeScript for the past 5+ years, gaining valuable insights from numerous projects. Now, I want to share everything I’ve learned along the way.</blockquote><blockquote>“This is just a glimpse! I’m currently writing a book <strong>‘You Don’t Know React Yet!’</strong> — Stay tuned for more updates.”<strong><em> 🚀</em></strong></blockquote><p>Want to support me? Consider buy me <a href="http://buymeacoffee.com/amandeepkochhar">a coffee</a>! ☕💙<br> 👉 <a href="https://buymeacoffee.com/amandeepkochhar">buymeacoffee.com/amandeepkochhar</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86f15335f401" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[JavaScript] — event.Target vs event.currentTarget]]></title>
            <link>https://amandeepkochhar.medium.com/javascript-event-target-vs-event-currenttarget-57b22d44ebc4?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/57b22d44ebc4</guid>
            <category><![CDATA[dom]]></category>
            <category><![CDATA[currenttarget]]></category>
            <category><![CDATA[events]]></category>
            <category><![CDATA[target]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Mon, 03 May 2021 14:54:13 GMT</pubDate>
            <atom:updated>2021-05-03T14:59:37.890Z</atom:updated>
            <content:encoded><![CDATA[<p>event.target <strong>Points to element, which triggers the event.</strong></p><p>event.currentTarget <strong>Points to element, to which the Event Listener is attached to.</strong></p><p>Confused?</p><p>Let’s consider this example, where a button is nested inside a paragraph and both button and paragraph having click event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*NG3pWp707TYBsMLk0RlQgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*0_OPp-JieFcngNtCCWWB_g.png" /></figure><p>When we click on the paragraph the event.target and event.currentTarget points to the same element <strong>i.e paragraph</strong>. Because, element which triggers the event and element where event listener is attached are the same.</p><p>Now, what happens when we click on the Button, Click listener of the button get executed, event.target and event.currentTarget for this button again remains same.</p><p>But</p><p>Event also bubbled up to the parent element<strong> i.e Paragraph,</strong> Here the scenario is like this.<br>event.target points to the Button since button is the one who triggers the click event, but event.currentTarget points to the Paragraph and not button, since paragraph is the one where event listener is attached to.</p><p>Hoping now the difference between the event.target and event.currentTarget is cleared.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57b22d44ebc4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Node JS] — Auto Loading Routes with File System.]]></title>
            <link>https://amandeepkochhar.medium.com/node-js-auto-loading-routes-with-file-system-356bfee2a024?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/356bfee2a024</guid>
            <category><![CDATA[express]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Sun, 21 Feb 2021 11:22:19 GMT</pubDate>
            <atom:updated>2021-02-21T11:22:19.470Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Node JS] — Auto Loading Routes with File System.</h3><p>As our server has multiple API endpoints, our need for creating routes increases, along with increased demand of creating these routing files.</p><blockquote>Traditionally, we were importing every single file that pertains to a specific route, to the root file as a middle ware. This can however be cumbersome if we have hundreds of routes.</blockquote><p>To resolve this issue, let me show you a trick we can apply to auto-reload the express routes easily, so that you don&#39;t have to worry about importing them one by one in the root file of your Node JS application.</p><p><strong>W</strong>e can achieve it using the following line of code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eb_hZ2ba45Swq6wnZ5_Dkg.png" /><figcaption>Mapping out all the files that are in our routes directory</figcaption></figure><p>In the above example what i am doing is requiring all the files i have created in the routes folder using an iteration.</p><p>Hopefully you liked this little trick, any improvement in this method is welcomed as comments.</p><p>A clap and a follow will encourage me to write more about my coding journey :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=356bfee2a024" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use an ES6 modules in Node.js?]]></title>
            <link>https://amandeepkochhar.medium.com/use-an-es6-modules-in-node-js-9ccb73904278?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ccb73904278</guid>
            <category><![CDATA[modules]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[import-export]]></category>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Sun, 31 Jan 2021 10:51:19 GMT</pubDate>
            <atom:updated>2021-01-31T11:09:45.942Z</atom:updated>
            <content:encoded><![CDATA[<h3>Use ES6 modules in Node.js?</h3><p>Before Node version 13, we were using the <a href="https://www.npmjs.com/package/esm">esm npm</a> package and run our app.js using the commandnode -r esm app.js</p><p>With recent updates of Node, this is natively supported now. There are two ways we can achieve it</p><ul><li>Save the file with .mjs extension.</li><li>Add { &quot;type&quot;: &quot;module&quot; } in the nearest package.json.</li></ul><p>Note that we only have to do one thing from the above mentioned.</p><p>If we are using Node.js version 8–12, <em>save</em> the file with ES6 modules with .mjs extension and run it like:</p><pre>node --experimental-modules app.mjs</pre><blockquote>Leaving a clap will motivate me to write more useful tips related to JS.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ccb73904278" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Interview Question] — Find the largest and smallest word in a sentence!]]></title>
            <link>https://amandeepkochhar.medium.com/interview-question-find-the-largest-and-smallest-word-in-a-sentence-d1734ce784c?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1734ce784c</guid>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Wed, 08 Apr 2020 17:36:05 GMT</pubDate>
            <atom:updated>2020-04-08T17:36:05.462Z</atom:updated>
            <content:encoded><![CDATA[<p>Input — “This is a sentence and I am about to find out the largest and smallest word occurring in this line”</p><p>Output —</p><p>Largest Word — occurring</p><p>Smallest Word — a</p><p>Try on your own and leave a reply containing your way of doing so!</p><p>Solution — Used Decoder (an Android app) to create this solution because I was lazy enough to not to turn on the laptop 😁</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WOBkI_Pc5aoWFvssnZxZyQ.jpeg" /></figure><p>Explanation:</p><p>Step 1: Declare two variables to store largest and smallest word. Here assign the first word to the smallest variable because we want to make a comparison between words going forward (I have used array.split(‘ ‘) and picked word lying at the 0th index)</p><p>Step 2: Loop through each word and compare the length current iterating word with the initial word we are using (Remember we can find the length of string using .length just like we do for arrays)</p><p>For finding smallest word we are using currentWord.length &lt; initialWord.length and for largest we are using currentWord.length &gt; initialWord.length</p><p>Step 2: Reassign the word depending upon the Iterating word has smaller or larger length than the last Assigned Word length.</p><p>There maybe other far more optimised ways to achieve the same thing. I just shared my approach.</p><p>Do leave a comment how you should have gone for the solution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1734ce784c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Interview Question] — Get the product of all the elements of an array except the current Element…]]></title>
            <link>https://amandeepkochhar.medium.com/interview-question-get-the-product-of-all-the-elements-of-an-array-except-the-current-element-7ece254b3d0a?source=rss-792a6d14d963------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ece254b3d0a</guid>
            <dc:creator><![CDATA[Amandeep Kochhar]]></dc:creator>
            <pubDate>Wed, 08 Apr 2020 17:19:11 GMT</pubDate>
            <atom:updated>2020-04-08T17:19:11.676Z</atom:updated>
            <content:encoded><![CDATA[<h4>[Interview Question] — Get the product of all the elements of an array except the current Element and return the result as an array!</h4><p>Input — [2, 3,4,5]</p><p>Output — [60, 40,30,24]</p><p>Try on your own and leave a reply containing your way of doing so!</p><p>Solution — Used Decoder (an Android app) to create this solution because I was lazy enough to not to turn on the laptop 😁</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LdPkrd9NxYMpyzwATRtPcg.jpeg" /></figure><p>Explanation:</p><p>Step 1: Loop through the entire Array using map and not forEach. As I need to return an array (Remember, map() in JavaScript always returns an array and forEach doesn’t)</p><p>Step 2: Create a copy of the array for each iteration (Here I have used the Array.slice() but you can use Modern Spread Operator too). Copy of the array is needed as I am going to splice out the current Traversed element which will remove the element from the Given array!</p><p>Step 3: use the Index we took out from the second argument from map() and remove the current traversed element.</p><p>Step 4: Loop through the remaining elements of the array and start multiplying them and return the result!</p><p>There maybe other far more optimised ways to achieve the same thing. I just shared my approach.</p><p>Do leave a comment how you should have gone for the solution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ece254b3d0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>