<?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 Tanvir Ahamed on Medium]]></title>
        <description><![CDATA[Stories by Tanvir Ahamed on Medium]]></description>
        <link>https://medium.com/@tanvir-ahamed?source=rss-df21438346fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*z95IkaAIpVs-grVe</url>
            <title>Stories by Tanvir Ahamed on Medium</title>
            <link>https://medium.com/@tanvir-ahamed?source=rss-df21438346fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:14:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanvir-ahamed/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[Is JavaScript Single-Threaded? Let’s Break It Down!]]></title>
            <link>https://tanvir-ahamed.medium.com/is-javascript-single-threaded-lets-break-it-down-fdab0633ca6d?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdab0633ca6d</guid>
            <category><![CDATA[single-threaded-execution]]></category>
            <category><![CDATA[asynchronous-programming]]></category>
            <category><![CDATA[event-loop-in-js]]></category>
            <category><![CDATA[javascript-architecture]]></category>
            <category><![CDATA[javascript-basics]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Sat, 01 Mar 2025 11:27:23 GMT</pubDate>
            <atom:updated>2025-03-01T11:27:23.946Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*xqW9fW9xuXO9xDQmO9pzJA.png" /></figure><p>Hey there, fellow coder! 👋 If you’ve been working with JavaScript for a while, you’ve probably heard this phrase: “JavaScript is single-threaded.” But what does that even mean? And why does it matter? Don’t worry — I’ve got you covered. Let’s break it down in a way that’s easy to understand and (hopefully) fun to read!</p><h3>What Does Single-Threaded Mean?</h3><p>Imagine this: You’re at a coffee shop, and there’s only one barista. They can only make one drink at a time. If someone orders a complicated drink (looking at you, triple-shot soy latte people), everyone else has to wait until it’s done before their orders are taken care of.</p><p>That’s what single-threaded means for JavaScript. It can only do one thing at a time. There’s just one “barista” (aka the main thread) handling all the tasks.</p><p>So, if JavaScript is busy doing something, like fetching data or running a big calculation, it can’t do anything else until that task is finished.</p><h3>Why Is JavaScript Single-Threaded?</h3><p>Great question! Here’s the deal: When JavaScript was created back in 1995 (yes, it’s older than some of us!), it was meant to make web pages interactive. You know, things like:</p><ul><li>Clicking a button to show a pop-up.</li><li>Filling out forms.</li><li>Animating elements on the page.</li></ul><p>Back then, keeping things simple was the goal. A single-threaded model made sense because:</p><ol><li>No Confusion: Only one thing happens at a time, so no weird bugs from tasks stepping on each other’s toes.</li><li>Browser Safety: Imagine two threads trying to change the same button on your screen at the same time — it would be chaos!</li><li>It Worked! For basic web pages, single-threading was enough.</li></ol><p>Fast forward to today, and JavaScript is used for way more than just web pages (hello, Node.js!). But its single-threaded nature hasn’t changed.</p><h3>Wait… How Does JavaScript Handle Multiple Things at Once?</h3><p>Okay, here’s where things get interesting. Even though JavaScript is single-threaded, it has a clever trick up its sleeve: <strong>the event loop</strong>.</p><p>Let me explain with another coffee shop analogy:</p><ol><li>The barista (JavaScript) takes your order and starts making your drink.</li><li>While they’re waiting for the espresso machine (a slow task), they take the next customer’s order instead of just standing around.</li><li>When the espresso machine finishes, they come back and complete your drink.</li></ol><p>In JavaScript terms:</p><ul><li>The main thread (our barista) handles tasks like running your code.</li><li>If something takes time (like fetching data from a server), it gets handed off to a helper (like Web APIs or Node.js workers).</li><li>Once the task is done, it goes into a queue and waits for its turn to be processed by the main thread again.</li></ul><p>This process is called asynchronous programming, and it makes JavaScript feel like it can multitask — even though it’s technically still single-threaded.</p><h3>How Do Developers Write Non-Blocking Code?</h3><p>To make sure our apps don’t freeze while waiting for tasks to finish, we use tools like:</p><ol><li>Callbacks: Functions that run when something is done.</li></ol><ul><li>Example: “Call me when you’re finished brewing my coffee.”</li></ul><ol><li>Promises: A cleaner way to handle async tasks.</li></ol><ul><li>Example: “I promise I’ll let you know when your coffee is ready.”</li></ul><ol><li>Async/Await: The modern way to write asynchronous code that looks nice and clean.</li></ol><ul><li>Example: “I’ll wait patiently until my coffee is done.”</li></ul><p>Here’s a quick example of async/await in action:</p><pre>async function getCoffee() {<br>  console.log(&quot;Ordering coffee...&quot;);<br>  const coffee = await brewCoffee(); // Wait for the coffee to brew<br>  console.log(&quot;Coffee is ready:&quot;, coffee);<br>}<br>getCoffee();</pre><h3>Does Being Single-Threaded Hold JavaScript Back?</h3><p>Not really! Sure, being single-threaded might sound like a limitation, but JavaScript has evolved to handle almost anything you throw at it:</p><ul><li>Need heavy computations? Use Web Workers (background threads).</li><li>Want smooth animations? Use requestAnimationFrame.</li><li>Fetching data from an API? Async/await makes it easy-peasy.</li></ul><p>The truth is, its single-threaded nature actually makes JavaScript simpler and easier to work with — no worrying about messy bugs caused by multiple threads clashing with each other.</p><h3>Final Thoughts</h3><p>So yes, JavaScript is single-threaded — but that doesn’t mean it can’t handle multiple things at once. Thanks to its event loop and asynchronous programming tools, it’s more than capable of juggling tasks efficiently.</p><p>Next time someone asks you if JavaScript is single-threaded, you can confidently say: “Yes — but with some clever tricks up its sleeve!”</p><p><em>What do you think about JavaScript being single-threaded? Have you ever run into issues with blocking code or async programming? Share your thoughts in the comments — I’d love to hear from you!</em> 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdab0633ca6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 04: Mastering the “Fruit Into Baskets” Problem with Sliding Window ]]></title>
            <link>https://tanvir-ahamed.medium.com/day-04-mastering-the-fruit-into-baskets-problem-with-sliding-window-709c3da0a323?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/709c3da0a323</guid>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[data-structure-algorithm]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sliding-window-pattern]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Sat, 01 Mar 2025 04:15:35 GMT</pubDate>
            <atom:updated>2025-03-01T04:15:35.333Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*0ZtC4FF3OQXQqciQgj78Iw.jpeg" /></figure><p>Hey everyone! 👋<br> Welcome back to <strong>Day 04</strong> of my <strong>100 Days of Problem-Solving Challenge</strong>! Today, I explored another powerful application of the <strong>Sliding Window Pattern</strong>: solving the <em>Fruit Into Baskets</em> problem efficiently. 🍎🍌</p><h3>🍏 Problem of the Day: Fruit Into Baskets</h3><p>Imagine you’re a fruit picker, and you have two baskets to collect fruits while moving along a row of trees. Each tree grows only one type of fruit, and you can only carry <strong>at most two types</strong> at any given time.</p><p>Your goal? <strong>Find the longest subarray containing at most two distinct fruits</strong>.</p><h4>Problem Statement:</h4><p>Given an array fruits where fruits[i] represents the type of fruit on the i-th tree, return the <strong>length of the longest contiguous subarray</strong> containing at most <strong>two different</strong> types of fruit.</p><p>🔹 <strong>Example:</strong></p><pre>Input: fruits = [1, 2, 1, 2, 3]<br>Output: 4<br>Explanation: The longest valid subarray is [1, 2, 1, 2], which contains only two types of fruit.</pre><h3>🤔 Why Use Sliding Window?</h3><p>A <strong>brute-force</strong> solution would check all possible subarrays, leading to a <strong>time complexity of O(N²)</strong> — way too slow for large inputs! Instead, a <strong>Sliding Window</strong> helps us efficiently track the longest valid subarray by expanding and shrinking the window dynamically.</p><p>Here’s how:</p><ol><li>Expand the window by <strong>moving the right pointer</strong> until there are more than two distinct fruits.</li><li>Shrink the window by <strong>moving the left pointer</strong> until the window is valid again.</li><li>Keep track of the <strong>maximum length</strong> encountered.</li></ol><h3>🔥 My Sliding Window Solution</h3><pre>const totalFruit = (fruits) =&gt; {<br>  let left = 0;<br>  let maxLen = 0;<br>  let fruitCount = new Map();<br>  <br>  for (let right = 0; right &lt; fruits.length; right++) {<br>    fruitCount.set(fruits[right], (fruitCount.get(fruits[right]) || 0) + 1);<br>    <br>    while (fruitCount.size &gt; 2) {<br>      fruitCount.set(fruits[left], fruitCount.get(fruits[left]) - 1);<br>      if (fruitCount.get(fruits[left]) === 0) {<br>        fruitCount.delete(fruits[left]);<br>      }<br>      left++;<br>    }<br>    <br>    maxLen = Math.max(maxLen, right - left + 1);<br>  }<br>  return maxLen;<br>};</pre><pre>console.log(totalFruit([1, 2, 1, 2, 3])); // Output: 4</pre><h3>⚙️ How It Works</h3><p>1️⃣ <strong>Expand the window</strong> → Add fruits to the Map as we move right. 2️⃣ <strong>Shrink the window</strong> → If more than <strong>two distinct fruits</strong>, remove from the left. 3️⃣ <strong>Update max length</strong> → Track the longest valid subarray.</p><h3>🚀 Why This Solution is Efficient:</h3><p>✅ <strong>Time Complexity:</strong> O(N), as each element is processed at most twice (once when added, once when removed).<br> ✅ <strong>Space Complexity:</strong> O(1), since we store only two types of fruit at a time.</p><h3>🍇 Another Example:</h3><pre>console.log(totalFruit([0, 1, 2, 2])); // Output: 3</pre><p>Here, the longest subarray is [1, 2, 2], which contains only two types of fruit and has a length of <strong>3</strong>.</p><h3>🌱 What I Learned Today:</h3><p>🔹 The <strong>Sliding Window</strong> is perfect for optimizing <strong>longest subarray</strong> problems.<br> 🔹 Tracking elements in a <strong>Map</strong> helps efficiently remove unnecessary values.<br> 🔹 Expanding and shrinking <strong>dynamically</strong> is the key to reducing complexity.</p><h3>🎯 What’s Next?</h3><p>Tomorrow, I’ll explore <strong>more advanced Sliding Window problems</strong>, including cases with additional constraints. Stay tuned! 🚀</p><h3>🚀 Follow My Journey:</h3><p>I’m documenting my problem-solving progress every day. If you’re on a similar journey or love discussing algorithms, let’s connect! Drop your thoughts, questions, or alternative approaches in the comments! 🔥</p><p>🌟 Let’s keep coding and improving! Happy Problem-Solving! 💪💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=709c3da0a323" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 03: Today, I uncovered the magic of dynamically adjusting window sizes to solve complex coding…]]></title>
            <link>https://tanvir-ahamed.medium.com/day-03-today-i-uncovered-the-magic-of-dynamically-adjusting-window-sizes-to-solve-complex-coding-bd95a1d243ee?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd95a1d243ee</guid>
            <category><![CDATA[100daysofcode]]></category>
            <category><![CDATA[javascript-coding-style]]></category>
            <category><![CDATA[sliding-window-pattern]]></category>
            <category><![CDATA[problem-solving]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Wed, 26 Feb 2025 18:19:47 GMT</pubDate>
            <atom:updated>2025-02-26T18:20:26.968Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 03: Today, I uncovered the magic of dynamically adjusting window sizes to solve complex coding problems efficiently. Curious how? Let’s dive in! 🚀</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*zuT0JnB4mmfDUitmwnhbyg.png" /></figure><p>Hey everyone! 👋<br>Welcome back to Day 03 of my <strong>100 Days of Problem Solving Challenge</strong>! Today, I dived deep into one of the most versatile techniques in problem-solving: the <strong>Sliding Window Pattern</strong> — but this time, with a twist. We’re exploring <strong>Dynamically Sized Windows</strong>!</p><h3>🔍 What is a Dynamically Sized Window?</h3><p>Unlike the fixed-length window, which keeps a constant size, a <strong>Dynamically Sized Window</strong> can expand or shrink based on specific conditions. This flexibility makes it incredibly useful for problems where the size of the subarray isn’t predetermined.</p><h3>Why Use Dynamically Sized Windows?</h3><ul><li>Efficiently manage subarrays of varying lengths.</li><li>Avoid recalculations by adjusting the window size dynamically.</li><li>Ideal for scenarios where conditions depend on sums, products, or other constraints.</li></ul><h3>🧠 Problem of the Day: Minimum Size Subarray Sum</h3><p>Today, I tackled a classic problem that perfectly illustrates the power of a dynamically sized window.</p><h3>Problem Statement:</h3><p>Given an array of positive integers nums and a positive integer target, find the <strong>minimum length</strong> of a contiguous subarray whose sum is greater than or equal to target.<br>If no such subarray exists, return 0.</p><h3>Example</h3><pre>Input: target = 7, nums = [2, 3, 1, 2, 4, 3]  <br>Output: 2</pre><p><strong>Explanation:</strong><br>The subarray [4, 3] has the minimum length of 2 and a sum of 7.</p><h3>🚀 Why Sliding Window?</h3><p>The naive approach would be to check every possible subarray, but this would be <strong>extremely inefficient</strong> with a time complexity of O(N2)O(N²)O(N2).</p><p>With a <strong>Dynamically Sized Sliding Window</strong>, we can:</p><ol><li><strong>Expand</strong> the window by moving the right pointer until the sum meets or exceeds the target.</li><li><strong>Shrink</strong> the window by moving the left pointer while maintaining the condition, there by minimizing the window size.</li></ol><p>This reduces the time complexity to O(N)O(N)O(N), making it a super-efficient solution! 💡</p><h3>🔥 My Sliding Window Solution:</h3><p>Here’s how I solved i</p><pre>const minSubArrayLen = (target, nums) =&gt; {<br>  let left = 0;<br>  let sum = 0;<br>  let minLength = Infinity;</pre><pre>// Expand the window by moving the right pointer<br>  for (let right = 0; right &lt; nums.length; right++) {<br>    sum += nums[right];<br>    // Shrink the window until the sum is less than the target<br>    while (sum &gt;= target) {<br>      minLength = Math.min(minLength, right - left + 1);<br>      sum -= nums[left]; // Shrink the window from the left<br>      left++;<br>    }<br>  }<br>  return minLength === Infinity ? 0 : minLength;<br>};<br><br>console.log(minSubArrayLen(7, [2, 3, 1, 2, 4, 3]));  // Output: 2</pre><h3>⚙️ How It Works:</h3><ol><li><strong>Expand the window:</strong></li></ol><ul><li>Move the right pointer to include elements in the current window.</li><li>Keep adding to the sum until the target is reached or exceeded.</li></ul><p><strong>2. Shrink the window:</strong></p><ul><li>Minimize the window size once the target is met by moving the left pointer.</li><li>Subtract the element at the left pointer and continue until the sum is less than the target.</li></ul><p><strong>3. Update the minimum length:</strong></p><ul><li>Keep track of the smallest window size that satisfies the condition.</li></ul><h3>🤯 Why This Solution is Efficient:</h3><ul><li><strong>Time Complexity:</strong> O(N)O(N)O(N) — Each element is added and removed from the window at most once.</li><li><strong>Space Complexity:</strong> O(1)O(1)O(1) — Only a few variables are used for calculations.</li></ul><p>This dynamic adjustment allows us to find the minimum subarray length without redundant calculations efficiently! 💪🔥</p><h3>✨ Another Example to Illustrate:</h3><pre>console.log(minSubArrayLen(11, [1, 2, 3, 4, 5]));  // Output: 3</pre><p>Here, the subarray [4, 5] is too small, but [3, 4, 5] has a sum of 12, meeting the target with a length of 3.</p><h3>🌱 What I Learned Today:</h3><ul><li>Dynamically sized windows are incredibly versatile and powerful for solving subarray problems.</li><li>Understanding when to <strong>expand</strong> and when to <strong>shrink</strong> is key to mastering this pattern.</li><li>Visualization helps! By imagining the window moving and adjusting, I could easily figure out the logic.</li></ul><h3>🎯 What’s Next?</h3><p>This is just the beginning of my journey with dynamically sized windows. Tomorrow, I’ll explore more challenging scenarios, including problems with more complex conditions and constraints. Stay tuned! 🚀</p><h3>🚀 Follow My Journey:</h3><p>I’m documenting my progress every day, sharing my learnings, code examples, and problem-solving strategies. If you’re on a similar journey or want to learn with me, feel free to <strong>connect and share your thoughts</strong> in the comments!</p><p>🔔 <strong>Follow me for more updates, and let’s grow together as better problem solvers!</strong></p><h3>🌟 Ready to Take on the Challenge?</h3><p>Let’s conquer the world of algorithms together! 💪🔥</p><p>Have questions or thoughts about today’s solution? Want to share your approach? Please drop a comment below, and let’s discuss!<br><strong>Happy Coding!</strong> 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd95a1d243ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top Programming Languages to Learn in 2025 — Boost Your Coding Skills]]></title>
            <link>https://tanvir-ahamed.medium.com/top-programming-languages-to-learn-in-2025-boost-your-coding-skills-03a90bdda982?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/03a90bdda982</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[tech-trends-2025]]></category>
            <category><![CDATA[career-development]]></category>
            <category><![CDATA[learning-programming]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Tue, 25 Feb 2025 06:37:20 GMT</pubDate>
            <atom:updated>2025-02-25T06:37:20.165Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Top Programming Languages You Should Learn in 2025 (And Why They Matter)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*qckpSwOl8I8fbWuEe2kruQ.jpeg" /></figure><p>Are you looking to boost your programming skills in 2025 but don’t know which language to start with? With countless programming languages out there, choosing the right one can be overwhelming. But don’t worry — whether you’re new to coding or looking to level up your career, I’ve got you covered.</p><p>I’ve done the research, and in this post, I’m sharing the <strong>top 6 programming languages</strong> that will dominate in 2025, with insights into why they matter and how they can impact your career. Let’s dive in!</p><h3>1. Python: The Go-To for AI, ML, and Data Science</h3><p><strong>Why it’s hot</strong>: Python’s versatility makes it a superstar for <strong>Artificial Intelligence</strong> (AI), <strong>Machine Learning</strong> (ML), <strong>data science</strong>, and <strong>web development</strong>. Its simple syntax and robust libraries like TensorFlow, NumPy, and Pandas make it a top choice for anyone interested in working with AI.</p><p><strong>Use case</strong>: Whether you’re building a recommendation system or diving deep into data analysis, Python is everywhere. And it’s in demand — <strong>Google</strong>, <strong>Spotify</strong>, <strong>Netflix</strong>, and more are all powered by Python.</p><p><strong>Tip</strong>: If you’re aiming to break into the AI or data science field, learning Python will be a game-changer for you. There’s never been a better time to get started!</p><h3>2. Java: A Classic That’s Here to Stay</h3><p><strong>Why it’s hot</strong>: Java has been around for decades, yet it’s still one of the most <strong>in-demand languages</strong> in the industry. Its <strong>stability</strong> and <strong>scalability</strong> make it the backbone of many large-scale applications, from <strong>enterprise systems</strong> to <strong>Android apps</strong>.</p><p><strong>Use case</strong>: Java powers everything from <strong>financial systems</strong> to <strong>Android</strong> apps. If you’re looking to work in enterprise software or mobile development, Java is a staple.</p><p><strong>Tip</strong>: Despite being older, Java isn’t going anywhere. If you’re interested in corporate or <strong>enterprise software</strong>, mastering Java will open doors to high-paying roles.</p><h3>3. JavaScript: The Language of the Web</h3><p><strong>Why it’s hot</strong>: JavaScript is at the heart of <strong>modern web development</strong>. It’s the engine that powers interactive websites, from scrolling animations to complex, data-driven applications. You can’t have a modern web experience without it.</p><p><strong>Use case</strong>: Whether you’re building a <strong>responsive website</strong>, a <strong>dynamic web app</strong>, or even a <strong>server-side application</strong> with Node.js, JavaScript is your tool of choice.</p><p><strong>Tip</strong>: If you’re a web developer or aspire to be one, JavaScript is non-negotiable. And with <strong>React</strong> and <strong>Vue</strong> frameworks taking over the frontend, knowing JavaScript gives you the flexibility to work on any web app.</p><h3>4. TypeScript: JavaScript’s Smarter, Safer Cousin</h3><p><strong>Why it’s hot</strong>: If you love JavaScript but want <strong>better type safety</strong> and <strong>error checking</strong>, <strong>TypeScript</strong> is the answer. It adds static typing to JavaScript, which helps developers catch bugs early in the development process.</p><p><strong>Use case</strong>: TypeScript is perfect for <strong>large-scale applications</strong>. It’s becoming the default choice for major frameworks like <strong>Angular</strong>, <strong>React</strong>, and <strong>Vue</strong>.</p><p><strong>Tip</strong>: If you’re already familiar with JavaScript, <strong>TypeScript</strong> is the next logical step. It will make you more productive and improve the quality of your code.</p><h3>5. SQL: The Backbone of Data Management</h3><p><strong>Why it’s hot</strong>: No matter the industry, <strong>data</strong> is key. And <strong>SQL</strong> (Structured Query Language) is the <strong>language of databases</strong>. It allows you to query and manipulate relational data with precision and efficiency.</p><p><strong>Use case</strong>: SQL is used for everything from <strong>managing customer data</strong> in e-commerce apps to <strong>analyzing massive datasets</strong> in data science. It’s a critical skill for anyone working with <strong>databases</strong> or <strong>back-end systems</strong>.</p><p><strong>Tip</strong>: If you’re working in data analysis, backend development, or even cloud computing, mastering SQL will set you apart in 2025.</p><h3>6. C++: The Language for High-Performance Applications</h3><p><strong>Why it’s hot</strong>: <strong>C++</strong> remains the go-to language for performance-critical applications, such as <strong>game engines</strong>, <strong>embedded systems</strong>, and <strong>real-time applications</strong>.</p><p><strong>Use case</strong>: If you’re looking to build anything that requires <strong>hardware-level optimization</strong> or <strong>real-time performance</strong> (think games, VR, or robotics), C++ is essential.</p><p><strong>Tip</strong>: C++ might seem intimidating, but it’s a must-have skill if you want to get into <strong>gaming</strong>, <strong>system programming</strong>, or any field requiring <strong>high-performance computing</strong>.</p><h3>So, Which Language Should You Learn?</h3><p>The key to choosing the right language is aligning your goals with the right tech stack.</p><ul><li><strong>For AI, Machine Learning, and Data Science</strong>: Go for <strong>Python</strong>.</li><li><strong>For Enterprise Applications and Android Development</strong>: Learn <strong>Java</strong>.</li><li><strong>For Web Development</strong>: Master <strong>JavaScript</strong> and consider <strong>TypeScript</strong> for better scalability.</li><li><strong>For Database Management</strong>: Learn <strong>SQL</strong>.</li><li><strong>For High-Performance Systems</strong>: Dive into <strong>C++</strong>.</li></ul><h3>My Advice: Start with What Excites You!</h3><p>The best way to stay motivated is by choosing a language that excites you. Don’t be afraid to experiment with different languages to find your niche. The tech world is vast, and there’s room for all kinds of developers — so go ahead and dive into a language that aligns with your passions and career goals!</p><p><strong>Got a favorite language?</strong> Drop it in the comments below! Let’s chat about how it’s helping you achieve your goals.</p><h3>Want to Learn More?</h3><p>Check out these resources to get started with these languages:</p><ul><li><a href="https://www.python.org/about/gettingstarted/">Python for Beginners</a></li><li><a href="https://www.oracle.com/java/technologies/javase-jdk11-downloads.html">Java Tutorials</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Introduction">JavaScript Crash Course</a></li><li>TypeScript Guide</li><li>SQL for Data Scientists</li><li><a href="https://www.learncpp.com/">Master C++</a></li></ul><h3>Final Thoughts: The Future is Bright for Coders in 2025!</h3><p>2025 is shaping up to be an exciting year in tech, with plenty of opportunities for developers who know the right languages. By focusing on languages like <strong>Python</strong>, <strong>Java</strong>, <strong>JavaScript</strong>, <strong>TypeScript</strong>, <strong>SQL</strong>, and <strong>C++</strong>, you’re positioning yourself for success in a rapidly changing industry.</p><p>So, which language will you start in 2025? Let me know in the comments!</p><p><strong>Engage with this post</strong>: If you found this helpful, share it with your friends and follow me for more insights on coding and tech career tips!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=03a90bdda982" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 02: Sliding Window Pattern (Part 2) — Maximum Average Subarray]]></title>
            <link>https://tanvir-ahamed.medium.com/day-02-sliding-window-pattern-part-2-maximum-average-subarray-483630f2faee?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/483630f2faee</guid>
            <category><![CDATA[sliding-window-pattern]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[coding-javascript]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Tue, 25 Feb 2025 05:44:47 GMT</pubDate>
            <atom:updated>2025-02-25T05:44:47.043Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 02: Sliding Window Pattern (Part 2) — Maximum Average Subarray</h3><p><strong>100 Days of Problem Solving Challenge</strong></p><p>Hey everyone! 👋<br>I’m back with Day 02 of my 100 Days of Problem Solving Challenge! 🚀<br>Continuing from yesterday, today I explored another fascinating application of the Sliding Window Pattern: <strong>Maximum Average Subarray</strong>. Let’s dive in!</p><h3>Problem Statement: Maximum Average Subarray I</h3><p>You are given an integer array nums consisting of n elements and an integer k.<br>Your task is to find the contiguous subarray of length k that has the maximum average value and return this maximum average.</p><h4>Example:</h4><p>Input: nums = [1, 12, -5, -6, 50, 3], k = 4<br>Output: 12.75<br>Explanation: The maximum average subarray is [12, -5, -6, 50] with an average of (12 - 5 - 6 + 50) / 4 = 12.75.</p><h3>Why Use Sliding Window?</h3><p>This problem is perfect for the Sliding Window Pattern because we are dealing with contiguous subarrays of a fixed length (k).<br>Instead of recalculating the sum for each subarray from scratch (which would take O(N * K) time), the Sliding Window Pattern allows us to efficiently slide the window by:</p><ol><li><strong>Adding</strong> the next element of the array.</li><li><strong>Removing</strong> the first element of the previous window.</li></ol><p>This reduces the time complexity to <strong>O(N)</strong>, making the solution much faster and more efficient!</p><h3>My Solution Using Sliding Window Pattern</h3><pre>const findMaxAverage = (nums, k) =&gt; {<br>  // Step 1: Calculate the sum of the first &#39;k&#39; elements<br>  let windowSum = 0;<br>  for (let i = 0; i &lt; k; i++) {<br>    windowSum += nums[i];<br>  }</pre><pre>// Step 2: Initialize maxSum with the first window sum<br>  let maxSum = windowSum;<br>  // Step 3: Slide the window through the array<br>  for (let i = k; i &lt; nums.length; i++) {<br>    windowSum += nums[i] - nums[i - k];  // Add next element, remove first element of previous window<br>    maxSum = Math.max(maxSum, windowSum);<br>  }<br>  // Step 4: Return the maximum average<br>  return maxSum / k;<br>};<br>// Example usage:<br>console.log(findMaxAverage([1, 12, -5, -6, 50, 3], 4));  // Output: 12.75</pre><h3>How It Works:</h3><ol><li><strong>Initialize the first window:</strong> Calculate the sum of the first k elements.</li><li><strong>Slide the window:</strong></li></ol><ul><li>Add the next element in the array.</li><li>Remove the first element of the previous window.</li></ul><p><strong>3. Update the maximum sum</strong> each time.</p><p><strong>4. Calculate the average</strong> by dividing the maximum sum by k.</p><h3>Why This Solution is Efficient:</h3><ul><li><strong>Time Complexity:</strong> O(N) — We only pass through the array once.</li><li><strong>Space Complexity:</strong> O(1) — Only a few variables are used for calculations.</li></ul><p>This approach avoids the need for nested loops or recalculations, ensuring optimal performance.</p><h3>What I Learned Today:</h3><ul><li>The Sliding Window Pattern is extremely effective for fixed-length subarray problems.</li><li>Visualizing the window’s movement helped me understand how to efficiently add and remove elements.</li><li>Breaking down the problem into smaller steps made it much easier to implement the solution.</li></ul><h3>What’s Next?</h3><p>This is just Part 2 of my exploration into the Sliding Window Pattern. Tomorrow, I’ll explore more complex problems, including <strong>variable-sized windows</strong> and more advanced scenarios.<br>The journey continues, and I’m excited to learn, grow, and share every step with you. If you’re on a similar journey or want to learn with me, feel free to connect and share your thoughts in the comments!</p><h3>Follow My Journey</h3><p>I’ll be documenting my progress every day, so don’t forget to follow me for more insights, code examples, and problem-solving strategies.<br>Let’s grow together as better problem solvers! 🌱</p><h3>Are you ready to take on the challenge too?</h3><p>Let’s crush it together! 💪🔥</p><p>Stay tuned for <strong>Day 03</strong>! 🚀<br>Happy coding! 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=483630f2faee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 01: Mastering the Sliding Window Pattern (Part 1) — 100 Days of Problem Solving Challenge]]></title>
            <link>https://tanvir-ahamed.medium.com/day-01-mastering-the-sliding-window-pattern-part-1-100-days-of-problem-solving-challenge-5667c9db2be0?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/5667c9db2be0</guid>
            <category><![CDATA[problem-solving-skills]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[sliding-windows]]></category>
            <category><![CDATA[coding-challenge]]></category>
            <category><![CDATA[sliding-window-algorithm]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Mon, 24 Feb 2025 18:45:37 GMT</pubDate>
            <atom:updated>2025-02-24T19:10:20.371Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 01: Mastering the Sliding Window Pattern (Part 1)</h3><p><strong>100 Days of Problem Solving Challenge</strong></p><p>Today marks the beginning of my <strong>100 Days of Problem Solving Challenge</strong>, and I’m thrilled to share my journey with you. 🚀 On Day 01, I dived into one of the most powerful and efficient techniques used to solve problems involving subarrays or substrings — the <strong>Sliding Window Pattern</strong>.</p><h3>🔍 What is the Sliding Window Pattern?</h3><p>The Sliding Window Pattern is an efficient approach for solving problems that involve a contiguous sequence of elements, like subarrays or substrings. It works by maintaining a “window” of elements and sliding it across the data structure to achieve an optimized solution.</p><h3>🔥 Why Use the Sliding Window Pattern?</h3><ul><li><strong>Efficiency:</strong> Reduces time complexity compared to brute force solutions.</li><li><strong>Performance:</strong> Avoids unnecessary recalculations by reusing the previous window’s result.</li><li><strong>Common Use Cases:</strong> Maximum/minimum sum of subarrays, longest substring with distinct characters, and many more.</li></ul><h3>💡 Example Problem</h3><p><strong>Find the maximum sum of any contiguous subarray of size </strong><strong>k in a given array.</strong></p><h3>💻 JavaScript Solution</h3><p>I implemented the solution using JavaScript to solidify my understanding. Here’s the code</p><pre>const arr = [2, 1, 5, 1, 3, 2];<br>const k = 3; // window size</pre><pre>const maxSumSubarray = (arr, k) =&gt; {<br>  let maxSum = 0;<br>  let windowSum = 0;<br>  let windowStart = 0;<br>  // Slide the window<br>  for (let windowEnd = 0; windowEnd &lt; arr.length; windowEnd++) {<br>    windowSum += arr[windowEnd]; // Add next element to the window<br>    // Check if we hit the window size<br>    if (windowEnd &gt;= k - 1) {<br>      maxSum = Math.max(maxSum, windowSum); // Update max sum<br>      console.log(<br>        `Sum of window [${arr.slice(<br>          windowStart,<br>          windowEnd + 1<br>        )}] = ${windowSum}`<br>      );<br>      windowSum -= arr[windowStart]; // Remove the element going out of the window<br>      windowStart++; // Slide the window forward<br>    }<br>  }<br>  return maxSum;<br>};<br>const result = maxSumSubarray(arr, k);<br>console.log(&quot;Maximum sum of any 3 consecutive numbers:&quot;, result);</pre><h3>🔎 How It Works:</h3><ol><li>We initialize maxSum, windowSum, and windowStart to zero.</li><li>We iterate through the array using windowEnd.</li><li>As we expand the window by including the current element, we check if we have hit the required window size (k).</li><li>If we have,</li></ol><ul><li>Compare and update maxSum with the current windowSum.</li><li>Slide the window forward by subtracting the element going out of the window and incrementing windowStart.</li></ul><h3>🔥 Output:</h3><pre>Sum of window [[2,1,5]] = 8<br>Sum of window [[1,5,1]] = 7<br>Sum of window [[5,1,3]] = 9<br>Sum of window [[1,3,2]] = 6<br>Maximum sum of any 3 consecutive numbers: 9</pre><h3>🚀 Key Takeaways:</h3><ul><li>The Sliding Window Pattern is great for solving problems involving contiguous subarrays.</li><li>It optimizes time complexity by reducing unnecessary calculations.</li><li>This pattern is widely used in competitive programming and technical interviews.</li></ul><h3>What I Learned Today</h3><ul><li>The <strong>Sliding Window Pattern</strong> is extremely powerful for optimizing problems involving contiguous subarrays or substrings.</li><li>It’s all about <strong>expanding and shrinking the window</strong> efficiently.</li><li>I learned to <strong>think in terms of windows</strong>, which helped me visualize the solution better.</li></ul><h3>What’s Next?</h3><p>This is just <strong>Part 1</strong> of my exploration into the Sliding Window Pattern. Tomorrow, I’ll dive deeper and explore <strong>variable-sized windows</strong> and more complex scenarios.</p><p>This journey is just beginning, and I’m excited to <strong>learn, grow, and share</strong> each step of the way. If you’re on a similar journey or want to learn with me, feel free to connect and share your thoughts in the comments!</p><p><strong>Stay tuned for Day 02!</strong> 🚀</p><h3>Follow My Journey</h3><p>I’ll be documenting my progress every day, so don’t forget to <strong>follow me</strong> for more insights, code examples, and problem-solving strategies.</p><p>Let’s <strong>grow together</strong> as better problem solvers! 🌱</p><p>Are you ready to take on the challenge too? Let’s crush it together! 💪🔥</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5667c9db2be0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why use UseEffect in React?]]></title>
            <link>https://tanvir-ahamed.medium.com/why-use-useeffect-in-react-ba7d7bd7b668?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba7d7bd7b668</guid>
            <category><![CDATA[useeffect]]></category>
            <category><![CDATA[useeffect-hook]]></category>
            <category><![CDATA[useeffect-hook-in-react]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Wed, 18 Dec 2024 14:39:46 GMT</pubDate>
            <atom:updated>2024-12-18T14:39:46.900Z</atom:updated>
            <content:encoded><![CDATA[<p>In React, the useEffect Hook is used to perform side effects in function components. Side effects are tasks that interact with something outside the React component, such as fetching data, setting up subscriptions, or manually manipulating the DOM.</p><p>Here’s why and when you use useEffect:</p><h3>1. Managing Side Effects</h3><ul><li>React components are declarative and focus on rendering UI based on state and props. However, some operations like fetching data or subscribing to events are imperative and considered side effects.</li><li>useEffect allows you to perform these tasks without cluttering your rendering logic.</li></ul><h3>2. Lifecycle Management</h3><ul><li>The useEffect hook effectively combines the behavior of componentDidMount, componentDidUpdate, and componentWillUnmount lifecycle methods in class components.</li><li>You can specify what the effect should do when the component.</li><li>Mounts (initial load).</li><li>Updates (state or props change).</li><li>Unmounts (cleanup before the component is removed).</li></ul><h3>3. Dependency Management</h3><ul><li>The second argument useEffect is a dependency array. It specifies when the effect should run.</li><li><strong>Empty array </strong><strong>[]</strong>: Run the effect only once, similar to componentDidMount.</li><li><strong>[dependencies]</strong>: Run the effect whenever the dependencies change.</li><li><strong>No array</strong>: Run the effect after every render, which is rarely efficient.</li></ul><h3>Common Use Cases for useEffect</h3><ol><li><strong>Fetching Data</strong></li></ol><pre>useEffect(() =&gt; {<br>    fetch(&#39;https://api.example.com/data&#39;)<br>        .then(response =&gt; response.json())<br>        .then(data =&gt; setData(data));<br>}, []); // Runs only once after the component mounts</pre><ol><li><strong>Subscribing to Events</strong></li></ol><pre>useEffect(() =&gt; {<br>    const handleResize = () =&gt; console.log(window.innerWidth);<br>    window.addEventListener(&#39;resize&#39;, handleResize);<br><br>    return () =&gt; window.removeEventListener(&#39;resize&#39;, handleResize); // Cleanup on unmount<br>}, []); // Runs once, subscribes on mount, and cleans up on unmount</pre><ol><li><strong>Updating DOM</strong></li></ol><pre>useEffect(() =&gt; {<br>    document.title = `New count: ${count}`;<br>}, [count]); // Updates the title whenever &#39;count&#39; changes</pre><ol><li><strong>Timers and Intervals</strong></li></ol><pre>useEffect(() =&gt; {<br>    const interval = setInterval(() =&gt; {<br>        setCount(prevCount =&gt; prevCount + 1);<br>    }, 1000);<br><br>    return () =&gt; clearInterval(interval); // Cleanup on unmount<br>}, []);</pre><h3>Summary</h3><p>useEffect is essential for handling side effects in functional components in a declarative, efficient, and readable way. It helps keep the logic clean and encapsulated while ensuring proper lifecycle management.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba7d7bd7b668" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top most React Interview question Part —]]></title>
            <link>https://tanvir-ahamed.medium.com/top-most-react-interview-question-part-b3877cd922d8?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3877cd922d8</guid>
            <category><![CDATA[react-interview-question]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-interview]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Sat, 23 Dec 2023 17:01:49 GMT</pubDate>
            <atom:updated>2023-12-23T17:01:49.509Z</atom:updated>
            <content:encoded><![CDATA[<h3>Top most React Interview question Part — 01</h3><ol><li><strong>Differentiate between Real DOM and Virtual DOM?</strong></li></ol><p>DOM means document object module. <strong>Real dom</strong> is an original dom of webpages on the other hand <strong>virtual dom</strong> is a representation of real dom. DOM is a tree structure. When an event occurs whole of the document will be updated in <strong>real DOM</strong>. But In <strong>virtual dom</strong> only updated which data has been event occurs. After the updated data or rendering code, virtual dom is faster than real dom.</p><p>2. <strong>What do you understand by Virtual DOM? Explain its works.</strong></p><p><strong>Virtual dom</strong> is a representation of real dom. DOM(document object module) is a tree of entire HTML web pages. When an event occurs or a state changes it only updates which data has been event occurs or state changes.This reason it more faster than real Dom and it was lightweight also.</p><p>3. <strong>What is React? why do you use react in the application?</strong></p><p>React is a javascript library developed by Facebook in 2011 and 2012. We can data updated without any reload. Because it has a virtual dom. Basically, virtual dom is a representation of real dom. We can only update which data needs to be updated. React state management system, UI reusable components, virtual dom which makes better performence and clean architecture.</p><p><strong>4. What are the key features of React?</strong></p><ol><li>JSX</li><li>Virtual dom</li><li>components</li><li>Performance</li><li>Extention</li><li>Clean code architecture</li></ol><p><strong>5. List some of the major advantages of React and What are the limitations of React?</strong></p><p><strong>Advantages :</strong></p><ol><li>Easy way to learn.</li><li>Seo friendly</li><li>JSX</li><li>Virtual dom</li><li>Components</li><li>Extention</li></ol><p><strong>Disadvantages :</strong></p><ol><li>Documentation complexity</li><li>Development Speed</li><li>JSX Complexity</li><li>Seo problem</li></ol><p><strong>6. what is JSX, and how does it work?</strong></p><p>JSX means javascript XML or javascript syntax extension. It allows us to write HTML and JavaScript code in our browser. The browser can&#39;t understand JSX. It only understands JavaScript.So we use babel which is javascript compiler or transpiler.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3877cd922d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Error Handling — Express JS]]></title>
            <link>https://tanvir-ahamed.medium.com/basic-error-handling-express-js-806f154c19d6?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/806f154c19d6</guid>
            <category><![CDATA[error-handling-in-express]]></category>
            <category><![CDATA[error-handling]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 15:47:00 GMT</pubDate>
            <atom:updated>2023-12-11T15:47:00.893Z</atom:updated>
            <content:encoded><![CDATA[<h3>Basic Error Handling — Express JS</h3><p>first of all, make a basic express setup.</p><pre>const express = require(&#39;express&#39;)<br>const app = express()<br><br>app.get(&#39;/&#39;, () =&gt; {<br>  throw new Error(&#39;This was an error&#39;)<br>})<br><br>app.listen(3000, ()) =&gt; {<br>  console.log(&#39;app listening at port 3000&#39;)<br>})</pre><p>Express has an invisible default error-handling middleware. It has 4 parameters -&gt; err, req, res, next.</p><pre>app.use((err, req, res, next) =&gt; {<br>  <br>})</pre><p>When a user sends a false URL we can use this error handling system.</p><pre>// 404 error handler<br>app.use((err, req, res, next) =&gt; {<br>  res.status(404).send(&#39;route not found&#39;)<br>})</pre><p>It is a custom error handling for all of the errors.</p><pre>app.use((err, req, res, next) =&gt; {<br>  if(err.message) {<br>  res.err(err.message)<br>}else{<br>  res.send(&#39;there is an error&#39;)<br>}<br>})</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=806f154c19d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering the foundation of express]]></title>
            <link>https://tanvir-ahamed.medium.com/mastering-the-foundation-of-express-db4ee1d00c0f?source=rss-df21438346fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/db4ee1d00c0f</guid>
            <category><![CDATA[node-js-development]]></category>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Sun, 19 Nov 2023 06:33:01 GMT</pubDate>
            <atom:updated>2023-11-19T06:33:01.859Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*D-0JFsdbaPg5DQ8jcCfKYw.jpeg" /></figure><p><strong># What is node js?</strong></p><p>Node.js is a single-threaded, open-source, cross-platform runtime environment. It runs on the V8 JavaScript runtime engine.</p><p><strong># Why node.js is popular?</strong></p><ul><li>We can use JavaScript on the server side.</li><li>Build highly scalable-backed applications.</li><li>It is single-threaded, event-driven, and works non-blocking I/O</li><li>Perfect building data-intensive, streaming application.</li></ul><p><strong># node.js modules</strong></p><ul><li>operating system Module (os)</li><li>File system module (fs)</li><li>Path Module (path)</li><li>HTTP Module (http)</li><li>URL Module (url)</li><li>Utilities Module (util)</li></ul><p><strong># What is a module?</strong></p><p>A module is an <strong>isolated</strong> and <strong>reusable</strong> block of code that has its <strong>own scope</strong>.</p><ul><li>Local Modules (We create)</li><li>Built-in modules (come with node js)</li><li>Third-party modules(created by others)</li></ul><p><strong>How to import export in node js :</strong></p><pre>// file name - local-1<br>const add1 = (num1, num2) =&gt; {<br>    return num1 + num2<br>}<br><br>const minus = (num1, num2) =&gt; {<br>    return num1 - num2<br>}<br><br>module.exports = {<br>  minus, add1<br>};</pre><pre>const {add1, minus} = require(&quot;./local-1&quot;);<br><br>const result = add1(5,6)<br>const result2 = minus(5,6)<br>console.log(result);<br>console.log(result2);</pre><p><strong>Path Module :</strong></p><p>By the path module, we can easily access the path of the file.</p><pre>const path = require(&#39;path&#39;)<br>console.log(path)</pre><pre>&lt;ref *1&gt; {<br>  resolve: [Function: resolve],<br>  normalize: [Function: normalize],<br>  isAbsolute: [Function: isAbsolute],<br>  join: [Function: join],<br>  relative: [Function: relative],<br>  toNamespacedPath: [Function: toNamespacedPath],<br>  dirname: [Function: dirname],<br>  basename: [Function: basename],<br>  extname: [Function: extname],<br>  format: [Function: bound _format],<br>  parse: [Function: parse],<br>  sep: &#39;\\&#39;,<br>  delimiter: &#39;;&#39;,<br>  win32: [Circular *1],<br>  posix: &lt;ref *2&gt; {<br>    resolve: [Function: resolve],<br>    normalize: [Function: normalize],<br>    isAbsolute: [Function: isAbsolute],<br>    join: [Function: join],<br>    relative: [Function: relative],<br>    toNamespacedPath: [Function: toNamespacedPath],<br>    dirname: [Function: dirname],<br>    basename: [Function: basename],<br>    extname: [Function: extname],<br>    format: [Function: bound _format],<br>    parse: [Function: parse],<br>    sep: &#39;/&#39;,<br>    delimiter: &#39;:&#39;,<br>    win32: [Circular *1],<br>    posix: [Circular *2],<br>    _makeLong: [Function: toNamespacedPath]<br>  },<br>  _makeLong: [Function: toNamespacedPath]<br>}</pre><p>Path module has many methods. We just talking about some important Path module methods.</p><pre>var path = require(&#39;path&#39;);<br><br>var moduleName= path.basename(&#39;file_path&#39;);<br>console.log(moduleName);</pre><p><strong>path.basename</strong> method returns the path extension.</p><h3>path.dirname(path)</h3><p>This method returns the directory name of the path. For example:</p><pre>const result = path.dirname(&#39;file_path&#39;);<br>console.log(result);</pre><p><strong># File system module, synchronous vs asynchronous</strong></p><p><strong>Reading file text(Synchronous way)</strong></p><pre>const fs = require(&#39;fs&#39;);<br>const readText = fs.readFileSync(&#39;./read.txt&#39;, &#39;utf-8&#39;)<br>console.log(readText);</pre><p><strong>Written file text(Synchronous way)</strong></p><pre>// Writting a text<br><br>const writeText = fs.writeFileSync(&#39;./write.txt&#39;, readText + &#39;Write this is&#39;)<br>console.log(writeText);</pre><p><strong>Reading file text(Asynchronous way)</strong></p><pre>fs.readFile(&#39;./read.txt&#39;, &#39;utf-8&#39;, (err, data) =&gt; {<br>    if (err) {<br>        throw Error(&#39;error reading&#39;)<br>    }<br>    console.log(data);<br>})</pre><p><strong>Written file text(Asynchronous way)</strong></p><pre>// write file asynchronouos way<br><br>const text = &#39;Tested text&#39;;<br>fs.writeFile(&#39;./test.txt&#39;, text, err =&gt; {<br>  if (err) {<br>    console.error(err);<br>  }<br>});</pre><p><strong>Event-Driven Architecture</strong></p><p><strong>Node.js</strong> is an event-driven platform that builds scalable network applications. It uses an event loop to handle asynchronous I/O operations.</p><p><strong>Event Emmiter(Emit Events) -&gt; Event Listener(Call) -&gt; Callback</strong></p><pre>const eventEmitter = require(&#39;events&#39;)<br>const myEmmiter  = new eventEmitter()<br><br>// listeners<br><br>myEmmiter.on(&#39;birthday&#39;, () =&gt; {<br>    console.log(&#39;Happy birthday&#39;);<br>})<br><br>myEmmiter.on(&#39;birthday&#39;, (gift) =&gt; {<br>    console.log(`Happy birthday ${gift}`)<br>})<br><br>myEmmiter.emit(&#39;birthday&#39;, &#39;watch&#39;)</pre><p><strong>Stream and Buffer :</strong></p><p>It is used to process data piece by piece which is called buffer.</p><ul><li>It is better in terms of user experience.</li><li>Needs short memory storage as it does not complete the whole process at once.</li></ul><p><strong>Different types of streams :</strong></p><ul><li>Readable stream — a steam whee we can read data</li><li>writable stream — a stream where we can write data</li><li>duplex stream — a stream for both write and read</li><li>Transform stream - a stream where can we reshape data</li></ul><p><strong>Readable Stream :</strong></p><pre>const fs = require(&#39;fs&#39;)<br><br>const ourREadStrean = fs.createReadStream(`${__dirname}/read.txt`)<br><br>ourREadStrean.on(&#39;data&#39;, (chunk) =&gt; {<br>    console.log(chunk.toString());<br>})</pre><p><strong>Writable Stream :</strong></p><pre>const fs = require(&#39;fs&#39;)<br><br>const writeStream = fs.createWriteStream(`${__dirname}/writeStream.txt`)<br><br>writeStream.on(&#39;New content&#39;, (chunk) =&gt; {<br> writeStream.write(chunk.toString())<br>})</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db4ee1d00c0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>