<?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 Sridhar Maskeri on Medium]]></title>
        <description><![CDATA[Stories by Sridhar Maskeri on Medium]]></description>
        <link>https://medium.com/@shridharmaskeri?source=rss-c18a7a86d7ac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DgoEA98XydOAZYYPjYxo-Q.png</url>
            <title>Stories by Sridhar Maskeri on Medium</title>
            <link>https://medium.com/@shridharmaskeri?source=rss-c18a7a86d7ac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:49:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shridharmaskeri/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[My Interview Experience at H&M for a Fullstack Engineer Role]]></title>
            <link>https://medium.com/@shridharmaskeri/my-interview-journey-at-h-m-for-a-fullstack-engineer-role-bac447792529?source=rss-c18a7a86d7ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/bac447792529</guid>
            <category><![CDATA[clothing]]></category>
            <category><![CDATA[software-engineer]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[full-stack-developer]]></category>
            <category><![CDATA[interview-questions]]></category>
            <dc:creator><![CDATA[Sridhar Maskeri]]></dc:creator>
            <pubDate>Sat, 26 Jul 2025 14:46:31 GMT</pubDate>
            <atom:updated>2025-07-26T15:01:39.049Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ULknyKoKo_ftn6ci" /><figcaption>Photo by <a href="https://unsplash.com/@itssecondkaki?utm_source=medium&amp;utm_medium=referral">Sei</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Earlier this month, I had the opportunity to interview with <strong>H&amp;M</strong> for a <strong>Fullstack Engineer</strong> position. The recruiter first came accross my profile through Naukri and then sent out a mail asking if I was interested in applying for the role.</p><p>The entire process was well-structured and insightful, consisting of four rounds: a <strong>hands-on assessment, an HR + behavioral discussion, a technical deep dive round, and a techno-managerial round</strong>. Here’s a breakdown of the experience, what was asked, and my takeaways from the journey.</p><h3>🧠 Round 1: Online Assessment</h3><p>The first round (90 mins) was conducted on the <strong>Codility platform</strong> and had two parts:</p><h3>1. SQL Query</h3><p>A question that tested my ability to work with joins, filtering, and subqueries.</p><h3>2. HTML Form Validation</h3><p>A pure HTML problem that required me to build a form with complete custom validation using only pure HTML5, CSS and JS.</p><h3>🗣️ Round 2: HR &amp; Behavioral Interview</h3><p>After 3–4 days of giving the online assessment, I got a call from the recruiter, informing that I had passed the assessment.</p><p>This round began with an overview of H&amp;M’s structure, business units, and the kind of work I would potentially be involved in.</p><h3>Questions Asked</h3><ul><li>Tell me about yourself (with a few follow-ups to dig deeper).</li><li>Why are you looking to make a switch?</li><li>Walk me through the projects you’ve worked on.</li></ul><h3>Behavioral Scenarios</h3><p>I was then given a few situational questions to assess my problem-solving, communication, and decision-making skills:</p><ol><li>A time I had to present something technical to a non-tech audience.</li><li>A situation where I realized a deployed solution had significant risks — and how I brought it up.</li><li>A scenario where I had to build a feature under heavy constraints (limited time, cost, or team).</li></ol><p>The discussion ended with questions about my CTC expectations, why I was expecting a particular hike, and what they could offer.</p><p>Soon after this round, the HR promptly scheduled the first technical interview, which was set to take place within the next 3–4 days.</p><h3>🧪 Round 3: Technical Interview</h3><p>This round was conducted by a <strong>Team Lead</strong> and a <strong>Senior Software Engineer, </strong>a deep technical discussion covering both frontend and backend technologies.</p><h3>Topics Covered</h3><ul><li><strong>Frontend</strong>: React, JavaScript/TypeScript, ES6+, HTML, CSS</li><li><strong>Backend</strong>: Node.js, Express, MySQL</li><li><strong>DevOps &amp; Integration</strong>: REST APIs, Git workflows</li><li><strong>Bonus Areas</strong>: Testing (Jest, Cypress), Infra-as-Code (Terraform, AWS CDK), Cloud (Azure), Auth (OAuth, Auth0, JWT)</li></ul><h3>Highlights</h3><ul><li>I was asked a few <strong>output-based code questions</strong> to test my understanding of <strong>scoping, hoisting, and closures</strong> in JavaScript.</li><li>Discussions on the <strong>React Context API vs Redux</strong>, especially performance implications and re-renders.</li><li>A deep dive into <strong>React Hooks</strong>, including useCallback, useMemo, useEffect, useLayoutEffect, and how they map to traditional lifecycle methods.</li><li>They tested my knowledge of the <strong>JavaScript and Node.js event loop</strong>, including microtasks, macrotasks, and phase execution.</li><li>I was asked about the <strong>security measures</strong> I’ve implemented to protect APIs, how I’ve used <strong>rate limiting</strong>, and my understanding of <strong>JWT-based authentication and refresh tokens</strong>.</li></ul><p>After the next day of the interview I got a callback from the recruiter informing me that the round had gone well and the final Hiring Manager round would be scheduled in the coming week.</p><h3>⚙️ Round 4: Techno-Managerial Round</h3><p>This was a concise yet focused discussion, led by the <strong>hiring manager</strong> and the <strong>team lead</strong>. It leaned more toward backend engineering and overall system design thinking.</p><h3>Highlights</h3><ul><li>Concepts around <strong>Node.js middleware</strong> and how to apply them conditionally.</li><li>Handling <strong>500 internal server errors</strong>, different types of <strong>HTTP status codes</strong>, and root cause analysis.</li><li>How I test my APIs using <strong>Jest</strong>, and whether I’ve worked with <strong>Cypress</strong>.</li><li>My team’s <strong>release process</strong> — including QA and deployment strategies.</li><li>My decision-making process while choosing <strong>npm packages</strong>, and when I prefer writing <strong>custom utility functions</strong>.</li><li>The hiring manager asked multiple questions about things I had mentioned in my resume.</li></ul><h3>✅ Final Verdict: Selected for the Role</h3><p>After a series of engaging and challenging rounds, I’m thrilled to share that I’ve been <strong>selected</strong> for the Fullstack Engineer role at H&amp;M! (Designation — Software Engineer)🎉</p><h3>🔑 My Key Takeaways</h3><ul><li>Brush up on <strong>core JavaScript concepts</strong> — hoisting, closures, event loop.</li><li>Be crystal clear on <strong>React internals</strong> and performance optimization patterns.</li><li>Know your <strong>backend, </strong>especially around API security and auth.</li><li>Learn to explain your work from both a <strong>technical and business perspective</strong>.</li></ul><p>If you’re preparing for a similar role, I hope this breakdown helps you structure your own prep better.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bac447792529" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polyfills for map, filter & reduce]]></title>
            <link>https://medium.com/@shridharmaskeri/polyfills-for-map-filter-reduce-232e04b28506?source=rss-c18a7a86d7ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/232e04b28506</guid>
            <category><![CDATA[polyfill-in-javascript]]></category>
            <category><![CDATA[js-array-method]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sridhar Maskeri]]></dc:creator>
            <pubDate>Sat, 22 Jun 2024 08:31:28 GMT</pubDate>
            <atom:updated>2024-06-22T10:51:32.543Z</atom:updated>
            <content:encoded><![CDATA[<p>Making Old Browsers Play Nice with Modern JavaScript 😎</p><h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFvIGAv1RLbb6A9i0eDgTg.png" /></figure><p>Hey there, fellow coders! 👋 Have you ever experienced the frustration of your shiny new JavaScript code working flawlessly in the latest Chrome, but then you test it on an older browser and it falls apart? 😱 Fear not! Today, we’re diving into the magical world of <strong>polyfills</strong> to save the day.</p><p>Polyfills are like those cool patches your grandma sews 🪡 on your old jeans. They make sure everything stays together, even if your wardrobe (or browser) is a bit outdated.</p><p>Specifically, we’ll be looking at polyfills for map, filter, and reduce—three essential methods that every JavaScript developer should have in their toolkit.</p><p><strong>Lets Get Started! 🥳</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FFo1cy8mqGDvbjpJBB7%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FFo1cy8mqGDvbjpJBB7%2Fgiphy.gif%3Fcid%3D790b76114qjaam0hpg9c6d4jik7mkzayqaro83i6jazxotsu%26ep%3Dv1_gifs_search%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdWtnOWk4dzY0Y2ZrNmw2endqbGM4MWtrcHBlbjd4dmQ3dXl1cGt5ZiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FFo1cy8mqGDvbjpJBB7%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/caec4e8c46550a8d476a5d70cc2dcf11/href">https://medium.com/media/caec4e8c46550a8d476a5d70cc2dcf11/href</a></iframe><h3>Understanding map, filter, and reduce</h3><p>Before we jump into the nitty-gritty, let’s have a quick refresher on what these methods actually do.</p><h4>map</h4><p>map is like a delivery drone 🚁 for your array. It takes each item, processes it (like putting a tiny package on it), and delivers a new array with all those packages.</p><p><strong>Parameters:</strong></p><ol><li>currentValue - The current element being processed.</li><li>index (optional) - The index of the current element.</li><li>array (optional) - The array map was called upon.</li></ol><p><strong>Example:</strong></p><pre>const numbers = [1, 2, 3, 4];<br>const doubled = numbers.map((n, i, arr) =&gt; {<br>  console.log(`Element: ${n}, Index: ${i}, Array: ${arr}`);<br>  return n * 2;<br>});<br>console.log(doubled); // [2, 4, 6, 8]</pre><h4>filter</h4><p>filter is the bouncer 🚷 of your array. It lets in only the elements that meet a certain criteria, kicking out the rest.</p><p><strong>Parameters:</strong></p><ol><li>currentValue - The current element being processed.</li><li>index (optional) - The index of the current element.</li><li>array (optional) - The array filter was called upon.</li></ol><p><strong>Example:</strong></p><pre>const numbers = [1, 2, 3, 4];<br>const evens = numbers.filter((n, i, arr) =&gt; {<br>  console.log(`Element: ${n}, Index: ${i}, Array: ${arr}`);<br>  return n % 2 === 0;<br>});<br>console.log(evens); // [2, 4]</pre><h4>reduce</h4><p>reduce is the magician 🎩 of the array world. It takes all your elements, combines them in a magical way, and produces a single value from them.</p><p><strong>Parameters:</strong></p><ol><li>accumulator - The accumulated value previously returned in the last invocation.</li><li>currentValue - The current element being processed.</li><li>index (optional) - The index of the current element.</li><li>array (optional) - The array reduce was called upon.</li></ol><p><strong>Example:</strong></p><pre>const numbers = [1, 2, 3, 4];<br>const sum = numbers.reduce((acc, n, i, arr) =&gt; {<br>  console.log(`Accumulator: ${acc}, Element: ${n}, Index: ${i}, Array: ${arr}`);<br>  return acc + n;<br>}, 0);<br>console.log(sum); // 10</pre><h3>Why Polyfills?</h3><p>You might be wondering 🤔, “Why do we need polyfills?”</p><p>Well, the sad truth is not all browsers are created equal. While modern browsers support map, filter, and reduce, older ones, do not. This is where polyfills come in — they fill the gap!</p><h3>Polyfilling map</h3><p>Here’s how you can polyfill map:</p><pre>if (!Array.prototype.map) {<br>  Array.prototype.map = function(callback) {<br>    const arr = this;<br>    const result = [];<br>    for (let i = 0; i &lt; arr.length; i++) <br>        result[i] = callback(arr[i], i, arr);<br>    }<br>    return result;<br>  };<br>}</pre><p><strong>Explanation</strong>: This code first checks if Array.prototype.map exists. If not, it defines the method. It loops through the array, applies the callback function to each element, and stores the result in a new array.</p><h3>Polyfilling filter</h3><p>Next up, filter:</p><pre>if (!Array.prototype.filter) {<br>  Array.prototype.filter = function(callback) {<br>    const arr = this;<br>    const result = [];<br>    for (let i = 0; i &lt; arr.length; i++) {<br>      if (callback(arr[i], i, arr)) {<br>        result.push(arr[i]);<br>      }<br>    }<br>    return result;<br>  };<br>}</pre><p><strong>Explanation</strong>: Similar to the map polyfill, this code defines Array.prototype.filter if it doesn’t exist. It applies the callback function to each element and includes only those elements that pass the test in the new array.</p><h3>Polyfilling reduce</h3><p>Finally, let’s tackle reduce:</p><pre>if (!Array.prototype.reduce) {<br>  Array.prototype.reduce = function(callback, initialValue) {<br>    let accumulator = initialValue;<br>    for (let i = 0; i &lt; this.length; i++) {<br>      accumulator = accumulator ? callback(accumulator, this[i], i, this) : this[i];<br>    }<br>    return accumulator;<br>  };<br>}</pre><p><strong>Explanation</strong>: This polyfill checks if reduce exists, and if not, defines it. It processes each element in the array, combining them into a single value as defined by the callback function. If no initial value is provided, the first element is used as the initial value.</p><h3>Bringing It All Together</h3><p>Polyfills ensure that your code runs smoothly, even on older browsers. Here’s a quick recap:</p><ul><li>map transforms each element of an array.</li><li>filter selects elements based on a test.</li><li>reduce combines elements into a single value.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F1QffP8E6nk4gKYZO5S%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F1QffP8E6nk4gKYZO5S%2Fgiphy.gif%3Fcid%3D790b7611hqrxe642bx7zku4334dx46tx9pptc20ecniksdda%26ep%3Dv1_gifs_search%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExYTA1czZyZnd0czBnejhjaTR3aXJ0aHZ2bThzZXVyaGViYTI2MWxxaiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F1QffP8E6nk4gKYZO5S%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="248" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbf37beaf31df1e02c987f8e6d52240e/href">https://medium.com/media/cbf37beaf31df1e02c987f8e6d52240e/href</a></iframe><h3>Conclusion</h3><p>Polyfills are a lifesaver for making sure your modern JavaScript runs smoothly on older browsers. By understanding and implementing these polyfills, you’re not just writing code; you’re writing resilient, inclusive code. Happy coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=232e04b28506" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the JavaScript Event Loop]]></title>
            <link>https://medium.com/@shridharmaskeri/understanding-the-javascript-event-loop-with-a-simple-example-d8d6e6dd5db4?source=rss-c18a7a86d7ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8d6e6dd5db4</guid>
            <category><![CDATA[queue]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[event-loop]]></category>
            <category><![CDATA[call-stack]]></category>
            <dc:creator><![CDATA[Sridhar Maskeri]]></dc:creator>
            <pubDate>Sat, 08 Jun 2024 13:13:27 GMT</pubDate>
            <atom:updated>2025-05-21T05:30:43.501Z</atom:updated>
            <content:encoded><![CDATA[<p>Event loop is a crucial concept for understanding how JavaScript handles <strong>asynchronous operations</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5oEzthpLeWcMAjnsmhOTug.png" /></figure><h3>Event Loop Introduction</h3><p>JavaScript is <strong>single-threaded</strong>, meaning it executes code in a single sequence, one operation at a time. The <strong>event loop</strong> allows JavaScript to perform non-blocking operations by offloading tasks to the browser or a background thread and continuing execution without waiting for those tasks to complete.</p><h3>Here’s how the event loop works in JavaScript</h3><ul><li><strong>Call Stack</strong>: A stack structure that keeps track of the currently executing function. When a function is called, it is added to the top of the stack. When the function returns, it is removed from the stack.</li><li><strong>Web APIs</strong>: These are provided by the browser (e.g: setTimeout, DOM events, AJAX calls). When an asynchronous function is called, it is handed off to the browser’s Web APIs.</li><li><strong>Callback Queue (Task Queue)</strong>: When an asynchronous operation completes, its callback is placed in the callback queue. This queue waits for the call stack to be empty.</li><li><strong>Microtask Queue</strong>: Contains promises and other microtasks which are processed before the callback queue.</li><li><strong>Event Loop</strong>: Continuously checks the call stack and processes microtasks before moving to the callback queue.</li></ul><h3>Let’s understand it with the help of an example!</h3><pre>console.log(&#39;Start&#39;);<br><br>setTimeout(() =&gt; {<br>  console.log(&#39;Timeout 1&#39;);<br>}, 1000);<br><br>setTimeout(() =&gt; {<br>  console.log(&#39;Timeout 2&#39;);<br>}, 0);<br><br>Promise.resolve().then(() =&gt; {<br>  console.log(&#39;Promise 1&#39;);<br>});<br><br>console.log(&#39;End&#39;);</pre><p>Let’s understand what the output would be by understanding how each line of code is executed.</p><ol><li><strong>Synchronous Code Execution</strong></li></ol><ul><li>console.log(&#39;Start&#39;) is called and added to the call stack. It prints &quot;Start&quot; and is then removed from the stack.</li><li>console.log(&#39;End&#39;) is called and added to the call stack. It prints &quot;End&quot; and is then removed from the stack.</li></ul><p><strong>2.</strong> <strong>Handling </strong><strong>setTimeout</strong></p><ul><li>setTimeout(() =&gt; { console.log(&#39;Timeout 1&#39;); }, 1000) is called and added to the call stack. The browser&#39;s Web API handles the timer. After 1000ms, the callback () =&gt; { console.log(&#39;Timeout 1&#39;); } is added to the callback queue. The initial setTimeout call is removed from the stack.</li><li>setTimeout(() =&gt; { console.log(&#39;Timeout 2&#39;); }, 0) is called and added to the call stack. The browser&#39;s Web API handles the timer. After 0ms, the callback () =&gt; { console.log(&#39;Timeout 2&#39;); } is added to the callback queue. The initial setTimeout call is removed from the stack.</li></ul><p><strong>3</strong>. <strong>Handling Promises</strong></p><ul><li>Promise.resolve().then(() =&gt; { console.log(&#39;Promise 1&#39;); }) is called. The Promise.resolve immediately resolves and the then callback () =&gt; { console.log(&#39;Promise 1&#39;); } is added to the microtask queue (also known as the job queue).</li></ul><p>4. <strong>Microtask Queue vs. Callback Queue</strong></p><ul><li>Microtasks (promises) have a higher priority than the callback queue (timers). So, before any task from the callback queue is processed, the event loop will first clear all microtasks.</li></ul><p>5. <strong>Event Loop Execution</strong></p><ul><li>The call stack is now empty. The event loop first checks the microtask queue.</li><li>The then callback () =&gt; { console.log(&#39;Promise 1&#39;); } is added to the call stack, executed, and prints &quot;Promise 1&quot;. It is then removed from the stack.</li><li>Next, the event loop checks the callback queue.</li><li>The setTimeout callback () =&gt; { console.log(&#39;Timeout 2&#39;); } is added to the call stack, executed, and prints &quot;Timeout 2&quot;. It is then removed from the stack.</li><li>Finally, after 1000ms, the setTimeout callback () =&gt; { console.log(&#39;Timeout 1&#39;); } is added to the call stack, executed, and prints &quot;Timeout 1&quot;. It is then removed from the stack.</li></ul><h3>Output</h3><p>Now that we have understood how the flow of execution of the above code would be try to guess the output on your own…. If you guessed it , great job🫡, below is the output of the code.</p><pre>Start<br>End<br>Promise 1<br>Timeout 2<br>Timeout 1</pre><h3>Conclusion</h3><p>With this example, you should have a clearer grasp of how JavaScript handles tasks behind the scenes. Happy Coding! 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8d6e6dd5db4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a simple REST API using Node Js and Express]]></title>
            <link>https://medium.com/@shridharmaskeri/creating-a-simple-rest-api-using-node-js-and-express-3a5cc00c160a?source=rss-c18a7a86d7ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a5cc00c160a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Sridhar Maskeri]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 06:09:37 GMT</pubDate>
            <atom:updated>2023-04-02T07:19:13.474Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>In this blog, we will be creating a simple REST API using Node js and the Express framework.</strong></h4><figure><img alt="Thumbnail" src="https://cdn-images-1.medium.com/max/1024/1*7LZdvejPz8w75ZEGya0YfA.jpeg" /></figure><h3>Before we start coding, let’s try to understand the meaning of <strong>REST API</strong>🤔</h3><p><strong>REST</strong> stands for <strong>Representational State Transfer</strong>. It is a software architectural style that defines a set of constraints to be used for creating Web services. Simply put, <strong>REST API</strong> is a set of rules that allows different software systems to communicate with each other. It provides a way for two systems to send data back and forth, using the standard <strong>HTTP methods</strong> like GET, POST, PUT, DELETE, etc.</p><h3>Some prerequisite📃</h3><ul><li>Latest version of Node js installed in your system.</li><li>Postman installed in your system for API testing.</li></ul><h3>Let’s get Started! 🥳</h3><p>Now that we have got a basic understanding of what REST means, let’s start by creating a new Node.js project, let’s name it <strong>simple-rest-api-proj</strong>. Open up your terminal and run the following command:</p><pre>cd simple-rest-api-proj<br>npm init -y</pre><p>This will create a new <strong>package.json</strong> file in your current directory, which will contain all of the metadata and dependencies for your Node.js project.</p><p>Next, we will install the <strong>Express.js</strong> framework. To do this, run the following command:</p><pre>npm install express --save</pre><p>This will install the <strong>Express.js</strong> framework and save it as a dependency in your <strong>package.json</strong> file.</p><h3>Now that we have the Express.js framework installed, let’s create a simple server that will handle HTTP requests 🤝</h3><p>Create a new file called <strong>server.js</strong> in your project’s root directory and add the following code:</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br><br>// Start the server<br>const port = process.env.PORT || 3000;<br>app.listen(port, () =&gt; console.log(`Listening on port ${port}...`));</pre><p>This code creates a new instance of the <strong>Express.js</strong> framework and listens for incoming HTTP requests on <strong>port 3000</strong>.</p><p>Next, let’s create our first API endpoint. Add the following code to your <strong>server.js</strong> file:</p><pre>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(&#39;Hello World!&#39;);<br>});</pre><p>This code creates a new route that responds to <strong>GET</strong> requests to the ‘<strong>/</strong> ’ path. When a <strong>GET</strong> request is received, the server will send a response with the text “<strong>Hello World!</strong>”.</p><p>Now that we have our first API endpoint, let’s start the server and test it out. Run the following command to start the server:</p><pre>node server.js</pre><p><strong>Great!</strong>😎 now that we have created the express and node server, now let’s move on to creating the REST API, so that we can perform <strong>CRUD </strong>Operations on the data <strong>(CRUD means — Create, Read, Update &amp; Delete)</strong>.</p><p>We will be using an in-memory object for this example, but you could easily modify it to use a database like <strong>MongoDB</strong> or <strong>MySQL</strong>.</p><p>Now, let’s modify <strong>sever.js </strong>by adding our products array to the same file</p><pre>// An in-memory array to store the data<br><br>let products = [<br>  { id: 1, name: &#39;Apple&#39;, price: 200 },<br>  { id: 2, name: &#39;Banana&#39;, price: 70 },<br>  { id: 3, name: &#39;Orange&#39;, price: 150 }<br>];</pre><h3>1. CREATE ✨</h3><p>Let’s first set up the middleware that helps us parse the incoming JSON request using <strong>express</strong></p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br><br>// Calling the express.json() method for parsing<br>app.use(express.json());<br><br>....</pre><p>Now, let’s create an endpoint that performs <strong>CREATE</strong> operation, which basically adds a product to the existing list of products.</p><pre>// A POST request to /products will add a new product to the array<br>app.post(&#39;/products&#39;, (req, res) =&gt; {<br>  // Read the request body to get the new product<br>  let newProduct = {id: 0, ...req.body};<br><br>  // Assign it a new id<br>  newProduct.id = products.length + 1;<br><br>  // Add it to the array<br>  products.push(newProduct);<br><br>  // Send the updated array back as the JSON response<br>  res.status(201).json(products);<br>});</pre><p>Testing the <strong>POST</strong> request using Postman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ULvGqVsxV5vAY_sbQweGgQ.png" /><figcaption>Adding a product to the list</figcaption></figure><h3>2. READ 📖</h3><p>Now, let’s create an endpoint that performs the <strong>READ</strong> operation, which basically returns the list of products to us.</p><pre>// A GET request to /products will return the array of products<br>app.get(&#39;/products&#39;, (req, res) =&gt; {<br>  res.json(products);<br>});</pre><p>Testing the <strong>GET</strong> request using Postman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9rYQ6ycYkKNa47C9I4rZiw.png" /><figcaption>Getting the list of all the products</figcaption></figure><h3>3. UPDATE 🔃</h3><p>Now, let’s create an endpoint that performs an <strong>UPDATE </strong>operation, which takes the id of a particular product and updates it.</p><pre>// A PUT request to /products/:id will update a product in the array<br>app.put(&#39;/products/:id&#39;, (req, res) =&gt; {<br>  // Read the request body to get the updated product<br>  let updatedProduct = {id:req.params.id, ...req.body};<br><br>  // Find the index of the product to be updated<br>  let index = products.findIndex(product =&gt; product.id == req.params.id);<br><br>  // Replace the product at that index with the updated product<br>  products[index] = updatedProduct;<br><br>  // Send the updated array back as the response<br>  res.json(products);<br>});</pre><p>Testing the <strong>PUT</strong> request using Postman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UMEpFbZ5ZIM3dcHFnqS0ng.png" /><figcaption>Updating a product from the list</figcaption></figure><h3>4. DELETE 🗑️</h3><p>Now, let’s create an endpoint that performs a <strong>DELETE </strong>operation, which takes the id of a particular product and deletes it.</p><pre>// A DELETE request to /products/:id will delete a product from the array<br>app.delete(&#39;/products/:id&#39;, (req, res) =&gt; {<br>  // Find the index of the product to be deleted<br>  let index = products.findIndex(product =&gt; product.id == req.params.id);<br><br>  // Remove the product at that index from the array<br>  products.splice(index, 1);<br><br>  // Send the updated array back as the response<br>  res.json(products);<br>});</pre><p>Testing the <strong>DELETE</strong> request using Postman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M7DdhN5VqNE-48YbRrdjsg.png" /><figcaption>Deleting a product from the list</figcaption></figure><p><strong>Congratulations! 🥳</strong> You have just created your first simple REST API using <strong>Node.js</strong> and <strong>Express.js</strong>. This API is capable of handling <strong>HTTP requests</strong> and sending <strong>responses</strong>, which is the fundamental functionality of a <strong>REST API</strong>.</p><h3>Here is the Link to the Github Repo</h3><p><a href="https://github.com/floating-dynamo/Simple-REST-API">GitHub - floating-dynamo/Simple-REST-API</a></p><p><strong>Don’t forget to follow me! 😉</strong></p><h3>Here are a few advanced learning resources on how to create REST API using node js 🚀</h3><ul><li><strong>Academind Playlist</strong> — <a href="https://www.youtube.com/playlist?list=PL55RiY5tL51q4D-B63KBnygU6opNPFk_q">https://www.youtube.com/playlist?list=PL55RiY5tL51q4D-B63KBnygU6opNPFk_q</a></li><li><strong>JavaScript Mastery</strong> — <a href="https://www.youtube.com/watch?v=l8WPWK9mS5M">https://www.youtube.com/watch?v=l8WPWK9mS5M</a></li><li><strong>MERN Stack playlist by Dave Gray</strong> — <a href="https://www.youtube.com/playlist?list=PL0Zuz27SZ-6P4dQUsoDatjEGpmBpcOW8V">https://www.youtube.com/playlist?list=PL0Zuz27SZ-6P4dQUsoDatjEGpmBpcOW8V</a></li></ul><h3>Happy Coding! 👋</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a5cc00c160a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hoisting  in JavaScript!]]></title>
            <link>https://medium.com/@shridharmaskeri/hoisting-in-javascript-1633eaa89aa8?source=rss-c18a7a86d7ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/1633eaa89aa8</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[hoisting]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sridhar Maskeri]]></dc:creator>
            <pubDate>Wed, 05 Oct 2022 06:44:00 GMT</pubDate>
            <atom:updated>2022-10-05T06:44:00.717Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ALmgqrsxRhn-tk2N0tfQGQ.jpeg" /><figcaption>Hoisting in Js</figcaption></figure><h3>Let’s understand what is <strong>hoisting</strong> in JavaScript and how does it work with the help of some examples 🌟</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VpHE5tHRcGgdVDqh2pQj9Q.png" /><figcaption>Example 1</figcaption></figure><p>The above code is a normal JavaScript program, whose output is:</p><ul><li><strong>Sridhar Maskeri</strong></li><li><strong>7</strong></li></ul><h3>What happens if we call the function while also attempting to print the variable <strong>before declaring them</strong>? 🤔</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TVFHb3eSs5cRxpOMU7UxZA.png" /><figcaption>Example 2</figcaption></figure><p>Now the output is:</p><ul><li><strong>Sridhar Maskeri</strong></li><li><strong>undefined</strong></li></ul><p>The phenomenon that occurs in the above example is called as <strong>Hoisting </strong>🚩<strong> in JavaScript.</strong></p><blockquote><strong>Hoisting</strong>🚩<strong> in JavaScript</strong> allows us to access variables and functions even before declaring or initialising them.</blockquote><p>The <strong>Creation phase</strong> and the <strong>Execution phase</strong> are the two distinct phases that make up each Execution Context, and each has its own distinct duties.✨</p><p>The JavaScript engine will begin the Global <strong>Creation</strong> phase by :</p><ol><li>Creating a <strong>global</strong> <strong>object</strong>.</li><li>Creating an object called “<strong>this</strong>”.</li><li>Setting up memory space for variables and functions.</li><li>Assigning variable declarations a <strong>default value</strong> of “<strong>undefined</strong>” while placing any function declarations in memory.</li></ol><p>In plain English, this means that the code is first scanned, the variables and functions are given a reserved area in the memory, and only then is the line-by-line execution of the code carried out.</p><p>This is the reason why the value of <strong>x</strong> is <strong>undefined</strong> in <em>Example 2.</em></p><h3>Now let’s try to print the value of <strong>x </strong>after it has been initialised. 🤠</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uy1XhFcMfpDNI9ud8j8bmA.png" /><figcaption>Example 3</figcaption></figure><p>Yes you got it right 👏, now the output will be:</p><ul><li><strong>undefined</strong></li><li><strong>7</strong></li></ul><h3>Now let’s try to print the value of a variable that is never initialised or declared. 🤠</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9eVQGZYu-JsaGsES_CfobQ.png" /><figcaption>Example 4</figcaption></figure><p><strong>Output :</strong></p><ul><li><strong>Sridhar Maskeri</strong></li><li>Here we get an error : <em>Uncaught ReferenceError: x is not defined</em></li></ul><p>Here we do not get <em>undefined </em>since the variable <em>x </em>is never declared or initialised in the entire program. 😯</p><h3>Let’s now examine what would happen if the function <em>getName()</em> was an <strong>arrow function. 🧐</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1iyrdOEB3AOw1s4m9-5CxA.png" /><figcaption>Example 5</figcaption></figure><p><strong>Output :</strong></p><p>We get an Error : <em>Uncaught TypeError : getName is not a function</em></p><p>This is because the <strong>arrow function</strong> acts as a <strong>variable rather than a function</strong>. Hence it initially stores the value <em>undefined. </em>😯</p><p>I hope you at least have a rudimentary understanding of hoisting now that you know what it is and how it works in JavaScript. 🤗</p><p><strong>Video Reference </strong>: <a href="https://www.youtube.com/watch?v=Fnlnw8uY6jo&amp;list=PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP&amp;index=4">https://www.youtube.com/watch?v=Fnlnw8uY6jo&amp;list=PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP&amp;index=4</a></p><p><strong>Happy Coding :) </strong>🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1633eaa89aa8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React — useEffect Hook , for Beginners!]]></title>
            <link>https://medium.com/@shridharmaskeri/react-useeffect-hook-for-beginners-9e610d8ba22f?source=rss-c18a7a86d7ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e610d8ba22f</guid>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[react-hook-useeffect]]></category>
            <category><![CDATA[useeffect]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Sridhar Maskeri]]></dc:creator>
            <pubDate>Fri, 29 Jul 2022 08:44:19 GMT</pubDate>
            <atom:updated>2022-07-29T08:53:23.726Z</atom:updated>
            <content:encoded><![CDATA[<h3>React — <strong>useEffect Hook</strong> 🪝, for Beginners!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJZzSrQXlku7I2AWoprSXQ.png" /></figure><h3>1. Creating a Counter which also changes the document title :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWOv_0AMUGwuH4-7C8RPzg.png" /><figcaption>Counter.jsx</figcaption></figure><p><strong>The Result :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*o9L6xSbV58dhQfThtA8mMA.png" /><figcaption>The Result of the Counter</figcaption></figure><p>Here in the above code, useEffect Hook calls the callback function when the <strong>page is loaded initially and also after every time the component renders</strong>.</p><h3>2. Conditionally running the useEffect Hook :</h3><p>Modifying the above code and adding an input element to create a state to store the input:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sMFsB-7lO4oD5Vsroric8A.png" /><figcaption>Counter.jsx</figcaption></figure><p><strong>The Result :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zCi1e0MuB8eHTXPFB9K8EQ.png" /><figcaption>UseEffect Hook called for every re-render</figcaption></figure><p>In the above code, the useEffect runs even if we try to type inside the input box, this is because the component re-renders every time we input text in the input box, trigerring the useEffect Hook which runs the callback function.</p><p>We do not want this to happen since this will make our code less optimal/efficient. Hence we want the document title to update <strong>only when we click the button(i.e : Only when the value of the count changes)!</strong></p><p>To achieve this we can pass a <strong>dependency list</strong> along with the callback function to the useEffect Hook.</p><p>The code can be changed to :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xk0OfHxZwgYOBQ_5bAiujA.png" /><figcaption>Conditional rendering</figcaption></figure><p><strong>The Result :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TDR3PUxF3j4uhe5zqNowTw.png" /><figcaption>UseEffect called only when count value changes</figcaption></figure><h3>3. Running useEffect Hook only once =&gt; On Loading the page :</h3><p>We will create a component that will find the x and y coordinates of the cursor on the browser window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r5RCvktUCodcBjszT9NdfA.png" /><figcaption>MouseExample.jsx</figcaption></figure><p>In the above code, we store the cursor coordinates in states and we use the <strong>Event Listener</strong> to track the mouse movement using <strong>mouseover event </strong>and we extract the position of x and y by <strong>e.clientX</strong> and <strong>e.clientY</strong>.</p><p><strong>The Result :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K0yrwQHW-WAnoYcAAzNPIQ.png" /><figcaption>useEffect is called every time we move the mouse cursor</figcaption></figure><p>In the above case, useEffect is called every time the component re-renders, and hence every time the listener is attached. We can avoid this by making it <strong>run only once</strong>.</p><p>The code can be changed to :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWHgvhwo0MRNTEsedBf4VA.png" /><figcaption>Running useEffect only once on page load</figcaption></figure><p>Hence the <strong>empty dependency list</strong> denotes that the useEffect is called only once, <strong>initially when the page loads</strong>.</p><h3>4. UseEffect with Cleanup :</h3><p>Timeouts, subscriptions, event listeners, and other effects that are no longer needed should be disposed, <strong>to reduce the memory leaks</strong>.</p><p>We do this by including a <strong>return function</strong> at the end of the useEffect Hook.</p><p>Creating another component which will includes the MouseExample component along with a button that toggles the MouseExample components view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ksdwj_A7h_MKqjeSEo4ocw.png" /><figcaption>MouseExample.jsx</figcaption></figure><p><strong>The Result :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ReYm1fHIhewQWd5EKideZA.png" /><figcaption>Button to toggle the view of the MouseExample component</figcaption></figure><p>On clicking the button , the variable <strong><em>display</em></strong> is set to <strong><em>false</em></strong> and hence the component is <strong>un-mounted.</strong></p><p>But if we move our cursor, the<strong><em> logMousePosition()</em></strong> function will still run, since the <strong>Event Listener</strong> is still listening for the event even tough the component has been <strong>un-mounted</strong>.</p><p>Hence we need to <strong>cleanup</strong> after the component is unmounted.</p><p>The code can be changed to :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wYLezwh_N_AOdV7U2CFuww.png" /></figure><p><strong>Reference :</strong> <a href="https://www.youtube.com/watch?v=06Y6aJzTmXY&amp;list=PLC3y8-rFHvwisvxhZ135pogtX7_Oe3Q3A&amp;index=6">https://www.youtube.com/watch?v=06Y6aJzTmXY&amp;list=PLC3y8-rFHvwisvxhZ135pogtX7_Oe3Q3A&amp;index=6</a></p><p>You can check Codevolution’s entire playlist of React Hooks : <a href="https://www.youtube.com/playlist?list=PLC3y8-rFHvwisvxhZ135pogtX7_Oe3Q3A">https://www.youtube.com/playlist?list=PLC3y8-rFHvwisvxhZ135pogtX7_Oe3Q3A</a></p><p>These videos really helped me get a grasp on all the different React Hooks :)</p><p>Hope you have found this useFull() 😂 and you now understand the basics of how to use the useEffect Hook! <strong>Happy Codding!!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e610d8ba22f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to publish your React App with Github Pages ]]></title>
            <link>https://medium.com/@shridharmaskeri/how-to-publish-your-react-app-with-github-pages-e77738da1b0c?source=rss-c18a7a86d7ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/e77738da1b0c</guid>
            <category><![CDATA[website]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Sridhar Maskeri]]></dc:creator>
            <pubDate>Tue, 07 Jun 2022 15:33:03 GMT</pubDate>
            <atom:updated>2022-06-07T15:53:32.338Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to publish your React App with Github Pages🚀</h3><figure><img alt="React+GithubPages" src="https://cdn-images-1.medium.com/max/1024/1*wUmVCbbOhYYzBiVOhv6kIg.jpeg" /></figure><h3><strong>Step 1 : Get your React App on Github</strong></h3><ul><li>Create new Repo.</li><li>Give it the name of your app.</li><li>Make it public.</li><li>Do not include a Read Me.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*auJcYAZt-cvefsxd5NjATg.png" /><figcaption>Adding Github Repo</figcaption></figure><h3>Step 2 : Add the final URL to package.json</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*RyNENvlWq1u-bGM5-8EHKA.png" /><figcaption>Adding URL to package.json</figcaption></figure><p>The name <strong>“example”</strong> at the end of the URL denotes the <strong>name of the Repository.</strong></p><p>The <strong>“USERNAME”</strong> is your <strong>Github account</strong> username.</p><h3>Step 3 : Push your React App to Your Github Repo</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*-HYX8PxppR1TCkdlXAQeTg.png" /><figcaption>Push App to Repo</figcaption></figure><p>Now if your default branch is <strong>“main”</strong> on Github and your default branch for your local setup is <strong>“master”</strong>, then convert master to main locally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*v15gHcOr2CjJ46300Ml3HQ.png" /><figcaption>master to main branch</figcaption></figure><h3>Step 4 : Add gh-pages npm package</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*1aSp0Rspu4nNFsRsFwy3iw.png" /><figcaption>Adding gh-pages npm package</figcaption></figure><blockquote>npm i gh-pages --save-dev</blockquote><h3>Step 5 : Add deploy scripts in package.json</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*xUr3aOZxE8r2k1Qk7QjhKg.png" /><figcaption>Adding deploy scripts</figcaption></figure><blockquote>“predeploy” : “npm run build”</blockquote><blockquote>“deploy” : “gh-pages -d build”</blockquote><h3>Step 6 : Deploy the React App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*vzmS1VFJlHnO9mKSTKAWBw.png" /><figcaption>Deploy React App</figcaption></figure><p>Wait for a few minutes for it to finish building and deploying your app.</p><p>You can now view your App at <strong>“https://USERNAME.github.io/REPO_NAME&quot;</strong></p><p><strong>Happy Coding!! :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e77738da1b0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>