<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Margish Patel</title>
    <description>The latest articles on DEV Community by Margish Patel (@margish288).</description>
    <link>https://dev.to/margish288</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1301257%2F942dfee1-17c2-4b0d-b066-277419a0eb84.jpg</url>
      <title>DEV Community: Margish Patel</title>
      <link>https://dev.to/margish288</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/margish288"/>
    <language>en</language>
    <item>
      <title>Mastering the app/ Directory: Your Gateway to Easy Routing 🚪</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Thu, 12 Sep 2024 05:21:55 +0000</pubDate>
      <link>https://dev.to/margish288/mastering-the-app-directory-your-gateway-to-easy-routing-43ai</link>
      <guid>https://dev.to/margish288/mastering-the-app-directory-your-gateway-to-easy-routing-43ai</guid>
      <description>&lt;p&gt;Welcome back developers! Its a chapter-2 of mastering the &lt;code&gt;next.js 13&lt;/code&gt; 👩‍💻👨‍💻 After your exciting first chapter ride, you’ve now hopped onto the &lt;code&gt;Next.js 13&lt;/code&gt; train. Buckle up because the next stop is one of the most game-changing features: the &lt;code&gt;app/&lt;/code&gt; directory. Think of it as that friend who’s really good at organising trips. With the app/ directory by your side, routing and navigation just became a whole lot easier. 🌟&lt;/p&gt;

&lt;h2&gt;
  
  
  A New Era of Routing 🗺️
&lt;/h2&gt;

&lt;p&gt;In the past, routing in Next.js was like following an old treasure map 🏴‍☠️—possible, but with a few “why-is-this-not-working” moments. Next.js 13 flips the script! With the &lt;code&gt;app/&lt;/code&gt; directory, you’re no longer wandering in the dark.&lt;/p&gt;

&lt;p&gt;Here’s why the &lt;code&gt;app/&lt;/code&gt; directory is your new best friend:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File-Based Routing 🗂️: Each folder in the &lt;code&gt;app/&lt;/code&gt; directory corresponds to a URL route. No need to define routes separately anymore—create a file, and boom 💥, you have a route.&lt;/li&gt;
&lt;li&gt;Layouts, Pages, and Components 🛠️: The &lt;code&gt;app/&lt;/code&gt; directory splits things into manageable pieces, like LEGO bricks 🧱. Want a universal layout? Done. Individual page structure? Easy. Component-based? You bet.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Now let’s see it in action with a simple project example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started with the &lt;code&gt;app/&lt;/code&gt; Directory: A Simple Project
&lt;/h2&gt;

&lt;p&gt;Let's create a basic setup for a Next.js 13 project using the &lt;code&gt;app/&lt;/code&gt; directory. It's so simple, it's almost &lt;em&gt;ridiculous&lt;/em&gt; how smooth it feels.&lt;/p&gt;

&lt;p&gt;1.Create a new Next.js project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest nextjs-app-dir
cd nextjs-app-dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Navigate to the &lt;code&gt;app/&lt;/code&gt; directory (it's pre-built!):&lt;br&gt;
You’ll notice a shiny new &lt;code&gt;app/&lt;/code&gt; directory sitting there waiting for you. Open it up and start making magic.&lt;/p&gt;

&lt;p&gt;3.Create your first page in the &lt;code&gt;app/&lt;/code&gt; directory:&lt;br&gt;
Inside &lt;code&gt;app/&lt;/code&gt;, create a new folder named about and within that, a file &lt;code&gt;page.tsx&lt;/code&gt; (this file represents your "About" page):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/about/page.tsx
export default function AboutPage() {
  return (
    &amp;lt;main&amp;gt;
      &amp;lt;h1&amp;gt;Welcome to the About Page&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;We're thrilled to have you here learning Next.js 13!&amp;lt;/p&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.Run your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.Visit &lt;code&gt;http://localhost:3000/about&lt;/code&gt; to see your new page live:&lt;/p&gt;

&lt;p&gt;Just like that, you’ve created an "About" page. 🥳 No messy routes, no headaches—just simple, intuitive file-based routing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layouts in the app/ Directory: Consistency is Key 🔑
&lt;/h2&gt;

&lt;p&gt;Okay, creating pages is easy, but what if you want the same layout across multiple pages? Maybe a consistent header or footer? The &lt;code&gt;app/&lt;/code&gt; directory has you covered. 💪&lt;/p&gt;

&lt;p&gt;1.Create a layout for all your pages: &lt;br&gt;
Inside the &lt;code&gt;app/&lt;/code&gt; directory, create a new file called &lt;code&gt;layout.tsx&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/layout.tsx
export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    &amp;lt;html lang="en"&amp;gt;
      &amp;lt;body&amp;gt;
        &amp;lt;header&amp;gt;
          &amp;lt;h1&amp;gt;My Awesome Next.js 13 Site&amp;lt;/h1&amp;gt;
        &amp;lt;/header&amp;gt;
        &amp;lt;main&amp;gt;{children}&amp;lt;/main&amp;gt;
        &amp;lt;footer&amp;gt;
          &amp;lt;p&amp;gt;© 2024 My Next.js App&amp;lt;/p&amp;gt;
        &amp;lt;/footer&amp;gt;
      &amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.&lt;strong&gt;Now every page will share this layout&lt;/strong&gt; — your “About” page just got a facelift! 🎨 All pages inside the &lt;code&gt;app/&lt;/code&gt; directory will now include this header and footer by default.&lt;/p&gt;




&lt;h2&gt;
  
  
  What’s the Point of Layouts? 🧐
&lt;/h2&gt;

&lt;p&gt;Layouts in &lt;code&gt;Next.js 13&lt;/code&gt; give you ultimate control. You can create nested layouts for different sections of your site. Need a different layout for your blog? Easy! 📝 Want to keep the same footer across your entire app? Done! ✨&lt;/p&gt;

&lt;p&gt;Think of layouts like building blocks — they let you structure your app in a way that makes sense without duplicating code across different pages.&lt;/p&gt;




&lt;h2&gt;
  
  
  Nested Layouts: Let’s Get Fancy 💅
&lt;/h2&gt;

&lt;p&gt;Let’s say you want a special layout for your "About" page:&lt;/p&gt;

&lt;p&gt;1.Inside the &lt;code&gt;app/about/&lt;/code&gt; folder, create a &lt;code&gt;layout.tsx&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/about/layout.tsx
export default function AboutLayout({ children }: { children: React.ReactNode }) {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;h2&amp;gt;About Us&amp;lt;/h2&amp;gt;
      &amp;lt;section&amp;gt;{children}&amp;lt;/section&amp;gt;
    &amp;lt;/&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, when you visit &lt;code&gt;/about&lt;/code&gt;, the new layout will be applied only to that section of your site. Cool, right?&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping It Up: The Power of the &lt;code&gt;app/&lt;/code&gt; Directory 🎁
&lt;/h2&gt;

&lt;p&gt;With the &lt;code&gt;app/&lt;/code&gt; directory, you’re not just getting easier routing—you’re getting a smoother development experience overall. Here’s a quick recap of the benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cleaner, Simpler Routing: No need for complicated route management.&lt;/li&gt;
&lt;li&gt;Layouts on Steroids: Global and nested layouts let you organize your app like a pro. 🏆&lt;/li&gt;
&lt;li&gt;File-Based Navigation: Folders and files = routes. That’s it. 🎯&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Your Next.js 13 Adventure Awaits 🎢
&lt;/h2&gt;

&lt;p&gt;You’re now well on your way to mastering &lt;code&gt;Next.js 13&lt;/code&gt;, one chapter at a time. But this is just the beginning! You’ve unlocked the power of the &lt;code&gt;app/&lt;/code&gt; directory, and you’re already on track to create scalable, maintainable applications with ease. 🎉&lt;/p&gt;

&lt;p&gt;In Chapter 3, we’ll dive into &lt;code&gt;File/Folder based routing and best practices&lt;/code&gt; and how they make your code maintainable and understandable. Until then, keep coding, and may your layouts always be in perfect harmony! 💻✨&lt;/p&gt;

&lt;p&gt;👨🏻‍💻Happy coding forks✨&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>chapter 1: Introduction to Next.js 13: What’s New? 🚀</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Sat, 07 Sep 2024 16:56:44 +0000</pubDate>
      <link>https://dev.to/margish288/chapter-1-introduction-to-nextjs-13-whats-new-48o7</link>
      <guid>https://dev.to/margish288/chapter-1-introduction-to-nextjs-13-whats-new-48o7</guid>
      <description>&lt;p&gt;Welcome, brave web explorers, to the wild and wondrous world of Next.js 13! 🌟 Buckle up, because we're about to embark on a journey through the latest and greatest features of this web development wizardry. Think of Next.js 13 as the shiny new spaceship in your web dev toolkit—ready to zoom past the old standards and into the future of modern web development. 🌌&lt;/p&gt;

&lt;h2&gt;
  
  
  The Tale of Next.js 13: What’s New? 🛸
&lt;/h2&gt;

&lt;p&gt;Picture this: you’re a web developer on a quest for the ultimate framework, and just when you thought you’d seen it all, Next.js 13 lands with a spaceship full of new features. Here’s what’s inside:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;App Directory (app/): The Magic Portal 🗺️ &lt;br&gt;
Imagine a magical portal that teleports you to the exact place you need to be. That’s the new app/ directory! It’s like upgrading from a GPS that sometimes leads you to the middle of nowhere to a trusty map that always gets you to your destination. This new feature simplifies routing and data fetching like never before. Say goodbye to those head-scratching moments of routing confusion!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;React Server Components: The Superpower ⚡&lt;br&gt;
Ever wish you had a superpower that made your code run faster and lighter? Enter Server Components, your new superpower. These components work their magic on the server and don’t even bother the client with unnecessary JavaScript. It’s like having a personal assistant who handles all the grunt work while you enjoy a coffee break. ☕&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Streaming: The Fast Lane 🏎️&lt;br&gt;
Imagine you’re on a highway with no speed limits—that’s what streaming in Next.js 13 feels like. HTML is streamed as it’s generated, so your pages load faster than a caffeinated squirrel on a mission. Your users will thank you for the speedy experience!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improved Image Component: The Glam Squad 📸&lt;br&gt;
Your images have been hitting the gym and are now in top shape! The new Image component is like having a glam squad for your visuals. It lazy loads by default, optimizes like a pro, and gives you more control. Your images are ready for their close-up!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Edge Functions: The Jetpack 🚀&lt;br&gt;
Picture having a jetpack that lets you deploy functions to the edge of the web world. Edge Functions in Next.js 13 give you low-latency responses and a performance boost that’s sure to impress your users, no matter where they are. 🌍&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Built-In API Routes: The Swiss Army Knife 🔧&lt;br&gt;
API routes in Next.js 13 are like a Swiss Army knife—versatile and ready for action. You can now build serverless functions directly within your application without breaking a sweat. It’s your all-in-one tool for handling server requests.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Benefits of Using Next.js for Modern Web Development
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Performance Optimization&lt;/li&gt;
&lt;li&gt;Enhanced Developer Experience&lt;/li&gt;
&lt;li&gt;Flexibility&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Your First Next.js 13 Adventure: A Simple Project 🎢
&lt;/h2&gt;

&lt;p&gt;Ready to dive in? Let’s create a basic Next.js 13 project and see the magic in action:&lt;/p&gt;

&lt;p&gt;Create a New Project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest my-next-app
cd my-next-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explore the New app/ Directory:&lt;/p&gt;

&lt;p&gt;Create a new file at app/page.tsx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/page.tsx
export default function HomePage() {
  return (
    &amp;lt;main&amp;gt;
      &amp;lt;h1&amp;gt;Welcome to Next.js 13&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;Explore the new features and improvements!&amp;lt;/p&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Your Project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; in your browser to see your new Next.js 13 application in action.&lt;/p&gt;

&lt;p&gt;Yey, there you have it, folks! we just completed 1 / 15 chapters of the mastering the nextjs !&lt;/p&gt;

&lt;p&gt;Stay tuned for chapter - 2, where we’ll delve deeper into the app/ directory and unlock more secrets of Next.js 13. Until then, may your code be bug-free and your coffee strong! ☕👨‍💻👩‍💻&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>React Server Components (RSC): The Future of Rendering in React 🔮</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Wed, 21 Aug 2024 08:01:50 +0000</pubDate>
      <link>https://dev.to/margish288/react-server-components-rsc-the-future-of-rendering-in-react-1hd</link>
      <guid>https://dev.to/margish288/react-server-components-rsc-the-future-of-rendering-in-react-1hd</guid>
      <description>&lt;p&gt;Remember when you first discovered React? It was like finding out your coffee never runs out—it just made life better. &lt;/p&gt;

&lt;p&gt;But just when you thought React couldn’t get any cooler, along comes something new that’s about to blow your mind: &lt;strong&gt;React Server Components (RSC)&lt;/strong&gt;. Imagine if your React app could be both &lt;em&gt;faster and smarter&lt;/em&gt; without you breaking a sweat. Sounds like magic, right? Well, let’s dive into the wizardry of &lt;strong&gt;RSC&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are React Server Components? 🎩🪄
&lt;/h2&gt;

&lt;p&gt;Picture this: &lt;em&gt;Your React components are like a rock band. The lead singer (client-side components) is out there in front, interacting with the crowd, while the drummer and bass player (server-side components) hold it all together in the background. Without them, the whole performance would fall apart&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpecokrjeygiloc6wlhvn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpecokrjeygiloc6wlhvn.gif" alt="music bands"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React Server Components (RSC) are those background players. Instead of running everything on the client (your user’s browser), RSC lets you do some of the heavy lifting on the server. It’s like sending your drummer to the recording studio so the lead singer doesn’t have to carry the whole show on their own. The result? A faster, more efficient app that still rocks.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does This Magic Work? ✨
&lt;/h2&gt;

&lt;p&gt;RSC is all about teamwork between the server and client:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server-Side:&lt;/strong&gt; Components that don’t need to be interactive (like fetching data or rendering static content) are handled by the server. It’s like getting a pre-packaged meal—everything’s ready to go, so your browser doesn’t have to cook it from scratch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client-Side:&lt;/strong&gt; Components that need to be interactive, like buttons or forms, still run on the client. But here’s the magic: the server-rendered components and client-rendered components are stitched together seamlessly, like a perfectly choreographed dance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No More Data Fetching Chaos:&lt;/strong&gt; With RSC, you don’t have to play the &lt;em&gt;“will it load in time?”&lt;/em&gt; game. The server fetches all the data it needs at once, sends down the final product, and voilà—no more waiting around for your data to arrive one drip at a time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Should You Care? 🚀
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Let’s be real: We all want our apps to be fast, efficient, and smooth as butter. Here’s why RSC is your new best friend:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Blazing Fast Load Times: By letting the server do the heavy lifting, your app loads quicker than a cat spotting a laser pointer.&lt;br&gt;
Less JavaScript, More Speed: The less JavaScript your browser has to deal with, the faster your app will be. RSC trims down the fat, leaving you with lean, mean, rendering machines.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SEO Boost: Since the server renders the HTML, search engines can easily crawl your pages, giving your SEO a nice little bump. It’s like finding out your pizza delivery guy also gives out free coupons.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Simplified Data Management: Let the server worry about fetching and managing data while you focus on making your app look awesome. No more juggling API calls on the client side—it’s all handled like a pro.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When Can You Start Using RSC? ⏳
&lt;/h2&gt;

&lt;p&gt;React Server Components are still in the oven, but they’re baking fast. They’re designed to work perfectly with other React goodies like Suspense and Concurrent Rendering, so once they’re fully cooked, you’ll be able to integrate them into your app without a hitch.&lt;/p&gt;

&lt;h2&gt;
  
  
  An Example: Let’s Build a Blog! 📝
&lt;/h2&gt;

&lt;p&gt;Imagine you’re building a blog. Some parts, like fetching and displaying posts, can be handled by the server. Meanwhile, the comment section, where users interact, is handled by the client.&lt;/p&gt;

&lt;p&gt;Here’s a sneak peek:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ServerComponent.js
export default function BlogPost({ id }) {
  const post = fetchPostFromDatabase(id); // Server-side fetch
  return &amp;lt;div dangerouslySetInnerHTML={{ __html: post.content }} /&amp;gt;;
}

// ClientComponent.js
export default function CommentSection({ postId }) {
  const [comments, setComments] = useState([]);

  useEffect(() =&amp;gt; {
    fetch(`/api/comments?postId=${postId}`)
      .then((res) =&amp;gt; res.json())
      .then((data) =&amp;gt; setComments(data));
  }, [postId]);

  return (
    &amp;lt;div&amp;gt;
      {comments.map((comment) =&amp;gt; (
        &amp;lt;p key={comment.id}&amp;gt;{comment.text}&amp;lt;/p&amp;gt;
      ))}
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;

&lt;p&gt;In this scenario, BlogPost gets rendered on the server, so your content is ready as soon as the user arrives. Meanwhile, Comment Section is interactive and rendered on the client, allowing users to jump in and start chatting without delay.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Future Is Here, and It’s Fast 🌟&lt;/strong&gt;&lt;br&gt;
React Server Components are about to change the game, making our apps faster, lighter, and smarter. While RSC is still in its experimental stage, it’s clear that this is the future of React development. So, buckle up and get ready to take your app to the next level&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope this version captures your interest! Let me know if there’s anything else you’d like to explore. 🚀&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Do you know Promises in JS ? (Basic)</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Thu, 04 Jul 2024 14:40:32 +0000</pubDate>
      <link>https://dev.to/margish288/do-you-know-promises-in-js-basic-1kk6</link>
      <guid>https://dev.to/margish288/do-you-know-promises-in-js-basic-1kk6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hey forks !&lt;br&gt;
In this blog post, we are going to explore 10 tricky JavaScript questions that test your understanding of Promises and asynchronous behaviour of Javascript.&lt;/p&gt;
&lt;h3&gt;
  
  
  What are Promises and how to handle it in JS ?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript Promises are a powerful tool for handling &lt;strong&gt;asynchronous operations&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;They represent a value that may be available now, in the future, or never. &lt;/li&gt;
&lt;li&gt;&lt;p&gt;Promises simplify complex asynchronous code by providing a more readable and maintainable structure. With methods like .then(), .catch(), and .finally(), Promises allow you to chain operations and handle errors gracefully.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Building on Promises, async and await are syntactic sugar that make asynchronous code look and behave more like synchronous code. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The async keyword declares an asynchronous function, which returns &lt;strong&gt;a Promise&lt;/strong&gt;, while the await keyword &lt;strong&gt;pauses the execution&lt;/strong&gt; until the Promise is resolved. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This modern approach simplifies &lt;strong&gt;error handling&lt;/strong&gt; and reduces the need for complex Promise chains, making your code cleaner and more maintainable. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Understanding Promises and async/await is essential for writing modern, efficient JavaScript code, especially when dealing with APIs, timers, or any asynchronous tasks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's start solving some basic promise related output based questions which might help you to crack the interviews.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example 1:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let p = new Promise((resolve, reject) =&amp;gt; {
  resolve("Hello");
});
p.then(value =&amp;gt; console.log(value));
console.log("World");

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;World
Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;console.log("World")&lt;/code&gt; executes immediately.&lt;/li&gt;
&lt;li&gt;The Promise resolves and logs "Hello" after the synchronous code has finished executing.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 2:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let p = new Promise((resolve, reject) =&amp;gt; {
  reject("Error");
});
p.catch(error =&amp;gt; console.log(error));
console.log("After promise");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;After promise
Error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;console.log("After promise")&lt;/code&gt; executes immediately.&lt;/li&gt;
&lt;li&gt;The Promise is rejected and logs "Error" after the synchronous code has finished executing.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 3:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let p = new Promise((resolve, reject) =&amp;gt; {
  resolve("First");
});
p.then(value =&amp;gt; {
  console.log(value);
  return "Second";
}).then(value =&amp;gt; console.log(value));
console.log("Third");

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Third
First
Second
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;console.log("Third")&lt;/code&gt; executes immediately.&lt;/li&gt;
&lt;li&gt;The Promise resolves and logs "First", then the chained then logs "Second".&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Example 4:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let p = Promise.resolve("Success");
p.then(value =&amp;gt; {
  console.log(value);
  throw new Error("Fail");
}).catch(error =&amp;gt; console.log(error.message));
console.log("Done");

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Done
Success
Fail
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;console.log("Done")&lt;/code&gt; executes immediately.&lt;/li&gt;
&lt;li&gt;The Promise resolves and logs "Success", then the error is caught and "Fail" is logged.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 5:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let p = new Promise((resolve, reject) =&amp;gt; {
  setTimeout(() =&amp;gt; resolve("Timeout"), 1000);
});
p.then(value =&amp;gt; console.log(value));
console.log("Immediate");

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Immediate
Timeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;console.log("Immediate")&lt;/code&gt; executes immediately.&lt;/li&gt;
&lt;li&gt;The Promise resolves after 1 second and logs "Timeout".&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 6:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function asyncFunc() {
  return "Async";
}
asyncFunc().then(value =&amp;gt; console.log(value));
console.log("Function");

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function
Async
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;console.log("Function")&lt;/code&gt; executes immediately.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;asyncFunc&lt;/code&gt; resolves and logs "Async" after the synchronous code has finished executing.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Example 7:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let p = new Promise((resolve, reject) =&amp;gt; {
  resolve("Resolved");
});
p.finally(() =&amp;gt; console.log("Finally"))
 .then(value =&amp;gt; console.log(value));
console.log("End");

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;End
Finally
Resolved
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;console.log("End")&lt;/code&gt; executes immediately.&lt;/li&gt;
&lt;li&gt;The Promise finally logs "Finally" and then logs "Resolved".&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 8:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function asyncFunc() {
  return new Promise((resolve, reject) =&amp;gt; {
    setTimeout(() =&amp;gt; resolve("Done"), 500);
  });
}
asyncFunc().then(value =&amp;gt; console.log(value));
console.log("Start");

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Start
Done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;br&gt;
The &lt;code&gt;console.log("Start")&lt;/code&gt; executes immediately.&lt;/p&gt;
&lt;h2&gt;
  
  
  The asyncFunc resolves and logs "Done" after 500ms.
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Example 9:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let p = Promise.resolve("First");
p.then(value =&amp;gt; {
  console.log(value);
  return Promise.resolve("Second");
}).then(value =&amp;gt; console.log(value));
console.log("Third");

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Third
First
Second
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;console.log("Third")&lt;/code&gt; executes immediately.&lt;/li&gt;
&lt;li&gt;The Promise resolves and logs "First", then the chained then logs "Second".&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 10:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function asyncFunc() {
  console.log("Inside function");
  return "Async";
}
asyncFunc().then(value =&amp;gt; console.log(value));
console.log("Outside function");

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Inside function
Outside function
Async
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The asyncFunc logs "Inside function" immediately.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;console.log("Outside function")&lt;/code&gt; executes immediately.&lt;/li&gt;
&lt;li&gt;The asyncFunc resolves and logs "Async" after the synchronous code has finished executing.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;p&gt;That’s all from my side, keep practising forks 🔥!!!&lt;br&gt;
🫡See you in next blog.&lt;/p&gt;

&lt;p&gt;Happy Coding 💻...&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>interview</category>
    </item>
    <item>
      <title>Do you have enough knowledge about object References in JS ? 🤯</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Wed, 03 Jul 2024 06:04:56 +0000</pubDate>
      <link>https://dev.to/margish288/do-you-have-enough-knowledge-about-object-references-in-js--4g7c</link>
      <guid>https://dev.to/margish288/do-you-have-enough-knowledge-about-object-references-in-js--4g7c</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hey forks !&lt;br&gt;
In this blog post, we are going to explore 10 tricky JavaScript questions that test your understanding of arrays, objects, and references. Each question comes with a detailed explanation to help you learn. Perfect for developers who want to improve their coding skills and understand JavaScript better.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example 1:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = [1, 2, 3];
let b = a;
b = [4, 5, 6];
a.push(4);

console.log(a);
console.log(b);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ 1, 2, 3, 4 ]
[ 4, 5, 6 ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initially, a and b both refer to the same array [1, 2, 3].&lt;/li&gt;
&lt;li&gt;b is then reassigned to a new array [4, 5, 6].&lt;/li&gt;
&lt;li&gt;When a.push(4) is called, it modifies the original array a, not the new array assigned to b.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 2:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let obj = { a: 1, b: { c: 2 } };
let newObj = Object.assign({}, obj);
newObj.b.c = 3;

console.log(obj.b.c);
console.log(newObj.b.c);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Object.assign() creates a shallow copy of obj.&lt;/li&gt;
&lt;li&gt;Both obj.b and newObj.b refer to the same object { c: 2 }.&lt;/li&gt;
&lt;li&gt;Changing newObj.b.c affects obj.b.c as well because they point to the same inner object.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 3:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr1 = [1, 2, 3];
let arr2 = arr1.map(x =&amp;gt; x * 2);
arr1.push(4);

console.log(arr1);
console.log(arr2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[1, 2, 3, 4]
[2, 4, 6]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;arr1 is [1, 2, 3].&lt;/li&gt;
&lt;li&gt;arr2 is created by mapping arr1 to [2, 4, 6].&lt;/li&gt;
&lt;li&gt;arr1.push(4) adds 4 to arr1, but does not affect arr2.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 4:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let obj1 = { a: 1 };
let obj2 = { b: 2 };
let obj3 = { ...obj1, ...obj2 };
obj1.a = 3;

console.log(obj3);

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ a: 1, b: 2 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;obj3 is created using the spread operator, combining obj1 and obj2.&lt;/li&gt;
&lt;li&gt;Modifying obj1.a does not affect obj3 because obj3 contains a copy of the properties of obj1 and obj2.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 5:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr = [1, 2, 3];
let arrCopy = JSON.parse(JSON.stringify(arr));
arr.push(4);
arrCopy.push(5);

console.log(arr);
console.log(arrCopy);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[1, 2, 3, 4]
[1, 2, 3, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON.parse(JSON.stringify(arr)) creates a deep copy of arr.&lt;/li&gt;
&lt;li&gt;Modifying arr does not affect arrCopy and vice versa.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 6:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let obj = { a: 1, b: 2 };
Object.freeze(obj);
obj.a = 3;
delete obj.b;

console.log(obj);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ a: 1, b: 2 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Object.freeze(obj) makes obj immutable.&lt;/li&gt;
&lt;li&gt;Any attempts to change properties or delete them are ignored.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 7:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const arr1 = [1, 2];
const arr2 = [...arr1];
arr2.push(3);

console.log(arr1);
console.log(arr2);

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[1, 2]
[1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The spread operator creates a shallow copy of arr1 into arr2.&lt;/li&gt;
&lt;li&gt;Modifying arr2 does not affect arr1.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 8:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function mutateObj(obj) {
  obj.a = 42;
}

let myObj = { a: 1 };
mutateObj(myObj);

console.log(myObj.a);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;42
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mutateObj modifies the property a of the passed object.&lt;/li&gt;
&lt;li&gt;The change is reflected in myObj.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 9:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const obj1 = { a: 1, b: 2 };
const obj2 = { ...obj1, a: 3 };
obj2.b = 4;

console.log(obj1);
console.log(obj2);

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

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ a: 1, b: 2 }
{ a: 3, b: 4 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The spread operator creates a shallow copy of obj1 into obj2, but with a overridden to 3.&lt;/li&gt;
&lt;li&gt;Modifying obj2 does not affect obj1.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Example 10:
&lt;/h3&gt;

&lt;p&gt;Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x = { y: { z: 1 } };
let y = { ...x };
y.y.z = 2;

console.log(x.y.z);
console.log(y.y.z);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output ✅:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Explanation 💡:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The spread operator creates a shallow copy of x.&lt;/li&gt;
&lt;li&gt;y.y and x.y refer to the same inner object { z: 1 }.&lt;/li&gt;
&lt;li&gt;Modifying y.y.z affects x.y.z as well.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>coding</category>
      <category>interview</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Throttling in JS</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Sun, 23 Jun 2024 19:16:10 +0000</pubDate>
      <link>https://dev.to/margish288/throttling-in-js-j44</link>
      <guid>https://dev.to/margish288/throttling-in-js-j44</guid>
      <description>&lt;h2&gt;
  
  
  Throttling
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Throttling&lt;/strong&gt; in JavaScript is a technique used to control the rate at which a function is executed. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This is especially useful in scenarios where a function could be called frequently, such as during &lt;strong&gt;scroll events&lt;/strong&gt;, &lt;strong&gt;window resizing&lt;/strong&gt;, or &lt;strong&gt;handling user input&lt;/strong&gt; in real-time. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By throttling a function, you ensure that it is not executed more often than a specified interval, thereby improving performance and responsiveness of the application.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg8602p4m7il15bijo7a.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg8602p4m7il15bijo7a.gif" alt="boy-throttles-bike" width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok ok we will not go into too much of theories and stuff but just remember that throttling means &lt;strong&gt;preventing a functional call which might called continuously&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Here's how throttling works...
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;So we have to just wrap our function into custom function which is implemented on top of &lt;code&gt;setTimeout()&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Have you ever work around closure concept of Javascript ?
&lt;/h3&gt;

&lt;p&gt;if no then this might look confusing...&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 : Main body of our wrapper function.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function throttle(func, delay) {
    return function (...args) {
        return func(...args);
    };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we will call this wrapper function like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function callApi() {
   // here comes the api call logic or any work you want to throttle.
}

const throttledFunction = throttle(callApi, 3000) // 3 in seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2 : Now we add timer to this function ⏰
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In next step we will understand why we are getting this timestamp.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function throttle(func, delay) {
    return function (...args) {
        const now = new Date().getTime(); // getting the timestamps

        return func(...args);
    };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3 : Some logic
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In here we have something interesting. I mean how do we compare old time with new one ? we probably need some logic right ?&lt;/li&gt;
&lt;li&gt;so here the actual part which is helping the wrapper function to call our passed function only and only if certain delay is passed.&lt;/li&gt;
&lt;li&gt;We have to keep track of &lt;code&gt;lastCall&lt;/code&gt; which is initially &lt;strong&gt;0&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;we update this lastCall every time with current time, in our case we set it with &lt;code&gt;now&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function throttle(func, delay) {
    let lastCall = 0;
    return function (...args) {
        const now = new Date().getTime(); // getting the timestamps
        lastCall = now;
        return func(...args);
    };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  step 4 : Putting some condition which adds throttle behaviour
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;we must have to compare our old time and new timer with passed &lt;code&gt;delay&lt;/code&gt; time and if it is less than passed &lt;code&gt;delay&lt;/code&gt; time then we have to return our function right away so out actual function will not call this time. &lt;/li&gt;
&lt;li&gt;it will wait for another time when this throttled function fires.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function throttle(func, delay) {
    let lastCall = 0;
    return function (...args) {
        const now = new Date().getTime(); // getting the timestamps
        if(now - lastCall &amp;lt; delay) {
          return;  
        }

        lastCall = now;
        return func(...args);
    };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;NOTE&lt;/em&gt;&lt;/strong&gt;: Sometime you might mess up around comparing timing in &lt;code&gt;if&lt;/code&gt; statement so i would suggest you to wrap your subtraction line with &lt;code&gt;abs(now - lastCall) &amp;lt; delay&lt;/code&gt; So we are on same line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TIP of the day 💡&lt;/strong&gt; : Its always good idea to write readable code so i would highly prefer you to give appropriate name and naming convention should be constant to your entire code base.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclution 🍫 🍩
&lt;/h3&gt;

&lt;p&gt;Yo buddy, &lt;strong&gt;Congratulations ! 🎉&lt;/strong&gt;  you just made your own throttling function. Go and use it in your code base.&lt;/p&gt;

&lt;p&gt;Reach out to me if you have any queries. I would love to answer you questions.&lt;/p&gt;

</description>
      <category>throttling</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>learndev</category>
    </item>
    <item>
      <title>99 Exciting Project Ideas! 🤯🔥</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Wed, 01 May 2024 06:29:56 +0000</pubDate>
      <link>https://dev.to/margish288/99-exciting-project-ideas-4kb9</link>
      <guid>https://dev.to/margish288/99-exciting-project-ideas-4kb9</guid>
      <description>&lt;p&gt;Are you also struggling to come up with project ideas for your next MERN stack adventure? Fear not! I've got you covered with this comprehensive list of 99 exciting projects to kickstart your creativity and hone your development skills.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F58kubhjhyxdc2ahr84gs.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F58kubhjhyxdc2ahr84gs.gif" alt="MERN PROJECT"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;List of projects : *&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Personal Blogging Platform&lt;/li&gt;
&lt;li&gt;To-Do List App&lt;/li&gt;
&lt;li&gt;Weather Forecasting App&lt;/li&gt;
&lt;li&gt;Recipe Management System&lt;/li&gt;
&lt;li&gt;Movie Review Website&lt;/li&gt;
&lt;li&gt;Expense Tracker&lt;/li&gt;
&lt;li&gt;Job Search Portal&lt;/li&gt;
&lt;li&gt;E-commerce Website (with basic functionality)&lt;/li&gt;
&lt;li&gt;Quiz Application&lt;/li&gt;
&lt;li&gt;Chat Application&lt;/li&gt;
&lt;li&gt;Social Media Dashboard&lt;/li&gt;
&lt;li&gt;Portfolio Website&lt;/li&gt;
&lt;li&gt;Online Bookstore&lt;/li&gt;
&lt;li&gt;Fitness Tracker&lt;/li&gt;
&lt;li&gt;Restaurant Finder&lt;/li&gt;
&lt;li&gt;Event Management System&lt;/li&gt;
&lt;li&gt;Task Management System&lt;/li&gt;
&lt;li&gt;Real Estate Listings&lt;/li&gt;
&lt;li&gt;Music Player Application&lt;/li&gt;
&lt;li&gt;Bug Tracker&lt;/li&gt;
&lt;li&gt;Car Rental System&lt;/li&gt;
&lt;li&gt;Online Learning Platform&lt;/li&gt;
&lt;li&gt;Cryptocurrency Tracker&lt;/li&gt;
&lt;li&gt;Recipe Sharing Platform (with user authentication)&lt;/li&gt;
&lt;li&gt;Pet Adoption Platform&lt;/li&gt;
&lt;li&gt;Employee Management System&lt;/li&gt;
&lt;li&gt;Appointment Booking System&lt;/li&gt;
&lt;li&gt;Blog Aggregator&lt;/li&gt;
&lt;li&gt;Movie Ticket Booking System&lt;/li&gt;
&lt;li&gt;Travel Planner&lt;/li&gt;
&lt;li&gt;News Aggregator&lt;/li&gt;
&lt;li&gt;Forum Website&lt;/li&gt;
&lt;li&gt;Polling Application&lt;/li&gt;
&lt;li&gt;Team Collaboration Tool&lt;/li&gt;
&lt;li&gt;Crowdfunding Platform&lt;/li&gt;
&lt;li&gt;Stock Market Tracker&lt;/li&gt;
&lt;li&gt;Charity Donation Platform&lt;/li&gt;
&lt;li&gt;Language Learning App&lt;/li&gt;
&lt;li&gt;Flashcard Generator&lt;/li&gt;
&lt;li&gt;Podcast Platform&lt;/li&gt;
&lt;li&gt;Resume Builder&lt;/li&gt;
&lt;li&gt;Task Scheduling Application&lt;/li&gt;
&lt;li&gt;Expense Sharing App&lt;/li&gt;
&lt;li&gt;Vehicle Maintenance Tracker&lt;/li&gt;
&lt;li&gt;Code Snippet Repository&lt;/li&gt;
&lt;li&gt;Virtual Classroom&lt;/li&gt;
&lt;li&gt;Survey Builder&lt;/li&gt;
&lt;li&gt;Recipe Recommendation System&lt;/li&gt;
&lt;li&gt;Gaming Leaderboard&lt;/li&gt;
&lt;li&gt;Freelancer Marketplace&lt;/li&gt;
&lt;li&gt;Budget Planner&lt;/li&gt;
&lt;li&gt;Movie Recommendation System&lt;/li&gt;
&lt;li&gt;Pet Health Tracker&lt;/li&gt;
&lt;li&gt;Project Management Tool&lt;/li&gt;
&lt;li&gt;Appointment Reminder System&lt;/li&gt;
&lt;li&gt;Employee Feedback System&lt;/li&gt;
&lt;li&gt;Social Networking Platform&lt;/li&gt;
&lt;li&gt;Classified Ads Website&lt;/li&gt;
&lt;li&gt;Job Board for Remote Work&lt;/li&gt;
&lt;li&gt;CRM (Customer Relationship Management) System&lt;/li&gt;
&lt;li&gt;Event Ticketing Platform&lt;/li&gt;
&lt;li&gt;Language Exchange Platform&lt;/li&gt;
&lt;li&gt;Ride-Sharing App&lt;/li&gt;
&lt;li&gt;Charity Fundraising Platform&lt;/li&gt;
&lt;li&gt;Food Delivery Service&lt;/li&gt;
&lt;li&gt;Podcast Recommendation System&lt;/li&gt;
&lt;li&gt;Subscription Management System&lt;/li&gt;
&lt;li&gt;Gaming Tournament Organizer&lt;/li&gt;
&lt;li&gt;Language Translation Tool&lt;/li&gt;
&lt;li&gt;Investment Portfolio Tracker&lt;/li&gt;
&lt;li&gt;Medical Appointment Scheduler&lt;/li&gt;
&lt;li&gt;Campus Events Portal&lt;/li&gt;
&lt;li&gt;Lost and Found Platform&lt;/li&gt;
&lt;li&gt;Mentorship Matching Platform&lt;/li&gt;
&lt;li&gt;Video Streaming Service&lt;/li&gt;
&lt;li&gt;Donation Management System&lt;/li&gt;
&lt;li&gt;Neighborhood Watch Platform&lt;/li&gt;
&lt;li&gt;Personal Finance Dashboard&lt;/li&gt;
&lt;li&gt;Task Automation Tool&lt;/li&gt;
&lt;li&gt;Public Transportation Scheduler&lt;/li&gt;
&lt;li&gt;Legal Document Generator&lt;/li&gt;
&lt;li&gt;Home Automation System&lt;/li&gt;
&lt;li&gt;Language Proficiency Test Platform&lt;/li&gt;
&lt;li&gt;Emergency Response System&lt;/li&gt;
&lt;li&gt;Skill Exchange Platform&lt;/li&gt;
&lt;li&gt;City Guide App&lt;/li&gt;
&lt;li&gt;Personal Journaling App&lt;/li&gt;
&lt;li&gt;Social Cause Awareness Platform&lt;/li&gt;
&lt;li&gt;Indoor Navigation System&lt;/li&gt;
&lt;li&gt;Restaurant Reservation System&lt;/li&gt;
&lt;li&gt;Cryptocurrency Exchange Platform&lt;/li&gt;
&lt;li&gt;Job Interview Preparation Platform&lt;/li&gt;
&lt;li&gt;Personalized News Aggregator&lt;/li&gt;
&lt;li&gt;Home Energy Monitoring System&lt;/li&gt;
&lt;li&gt;Talent Showcase Platform&lt;/li&gt;
&lt;li&gt;Campus Ride Sharing&lt;/li&gt;
&lt;li&gt;Emergency Medical Service Locator&lt;/li&gt;
&lt;li&gt;Property Management System&lt;/li&gt;
&lt;li&gt;Smart Parking System&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;go ahead, dive in, and let your imagination run wild.&lt;/p&gt;

&lt;p&gt;And hey!! why not help me complete this list to 100 by commenting with one more project idea? 😁&lt;/p&gt;

</description>
      <category>mern</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Speak Everyone's Language: A Guide to Multilingual React Apps! 🔯</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Tue, 09 Apr 2024 09:56:32 +0000</pubDate>
      <link>https://dev.to/margish288/speak-everyones-language-a-guide-to-multilingual-react-apps-3n2f</link>
      <guid>https://dev.to/margish288/speak-everyones-language-a-guide-to-multilingual-react-apps-3n2f</guid>
      <description>&lt;p&gt;In today's world, speaking everyone's language is super important for websites and apps. React, a cool tool for making websites, has some awesome tricks to help with that! In this blog, we're going to dive into how you can easily make your React app understand many languages. It's going to be fun, simple, and totally doable!&lt;/p&gt;

&lt;h2&gt;
  
  
  Cool Ways to Make Your App Multilingual:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. DIY Translations:
&lt;/h3&gt;

&lt;p&gt;We can start by doing it ourselves! Think of it like having a secret decoder ring for each language.&lt;br&gt;
We'll create special files for each language, like having different dictionaries.&lt;br&gt;
Then, when our app starts, we'll pick the right dictionary based on the language someone wants.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpq77es1eux9hlhzrurgs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpq77es1eux9hlhzrurgs.png" alt="Languages folder" width="754" height="356"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. React-Intl Magic:
&lt;/h3&gt;

&lt;p&gt;React-Intl is a powerful library for internationalization (i18n) in React applications.&lt;br&gt;
It's like having a language wizard in your app. It can do things like change numbers, dates, and words into any language.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { FormattedMessage, IntlProvider } from 'react-intl';

const messages = {
  en: {
    greeting: 'Hello!',
  },
  fr: {
    greeting: 'Bonjour!',
  },
};

function App() {
  const [locale, setLocale] = React.useState('en');

  return (
    &amp;lt;IntlProvider locale={locale} messages={messages[locale]}&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;&amp;lt;FormattedMessage id="greeting" /&amp;gt;&amp;lt;/h1&amp;gt;
        &amp;lt;button onClick={() =&amp;gt; setLocale('en')}&amp;gt;English&amp;lt;/button&amp;gt;
        &amp;lt;button onClick={() =&amp;gt; setLocale('fr')}&amp;gt;French&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/IntlProvider&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similar way there is also one library named &lt;code&gt;i18next&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Which approach do you use for your project?? 🤔 *&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Integrate sqlite with Nodejs ! 🔥</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Wed, 20 Mar 2024 08:53:38 +0000</pubDate>
      <link>https://dev.to/margish288/integrate-sqlite-with-nodejs--n55</link>
      <guid>https://dev.to/margish288/integrate-sqlite-with-nodejs--n55</guid>
      <description>&lt;p&gt;Hey there!!👋🏻, fellow developers! Are you ready to supercharge your Node.js applications with the incredible power of SQLite? Let's dive into the exciting world of SQLite3 module and see how it seamlessly integrates with Node.js to create jaw-dropping applications!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Requiring the SQLite3 Module
&lt;/h2&gt;

&lt;p&gt;To begin your journey with SQLite3, you first need to incorporate the module into your Node.js project. Simply use the require() function to import the sqlite3 module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Requiring the sqlite3 module
const sqlite3 = require('sqlite3');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you've included the module, you gain access of methods for seamless database operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Creating/Connecting to a Database
&lt;/h2&gt;

&lt;p&gt;In SQLite, databases are represented as individual files. The sqlite3.Database() method facilitates the creation or connection to a database file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Creating or connecting to a database file
const db = new sqlite3.Database('./my_database.sqlite');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this step, you establish a connection to your database, &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Fetching a Single Row: db.get() Method
&lt;/h2&gt;

&lt;p&gt;When you need to retrieve a single row from your database, the db.get() method proves invaluable. It executes a query and returns the first row matching the specified criteria:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Fetching the first row matching the query
db.get("SELECT * FROM users WHERE id = 1", (error, row) =&amp;gt; {
    if (error) {
        console.error(error.message);
        return;
    }
    console.log(row);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With db.get(), you can pinpoint and extract specific data from your database it return the first match of occurrence.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Fetching Multiple Rows: db.all() Method
&lt;/h2&gt;

&lt;p&gt;For scenarios requiring retrieval of multiple rows that meet certain conditions, the db.all() method comes to the rescue. It executes a query and returns all rows matching the specified criteria:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Fetching all rows from the 'products' table
db.all("SELECT * FROM products WHERE category = 'electronics'", (error, rows) =&amp;gt; {
    if (error) {
        console.error(error.message);
        return;
    }
    console.log(rows);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With db.all(), you can efficiently gather extensive datasets tailored to your application's needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Iterating Over Rows: db.each() Method
&lt;/h2&gt;

&lt;p&gt;The db.each() method empowers you to iterate over each row returned by a query, enabling custom actions to be performed on individual rows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Performing an action on each row from the 'orders' table
db.each("SELECT * FROM orders", (error, row) =&amp;gt; {
    if (error) {
        console.error(error.message);
        return;
    }
    console.log(row);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Utilizing db.each(), you can execute personalised operations on every row retrieved from your database.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Executing SQL Commands: db.run() Method
&lt;/h2&gt;

&lt;p&gt;When it comes to executing SQL commands that don't return data, such as table creation or row insertion, the db.run() method is your go-to solution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Creating a new table
db.run("CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT)");

// Inserting a new row into the table
db.run("INSERT INTO products (name) VALUES ('Laptop')");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With db.run(), you wield the power to manipulate your database schema and content effortlessly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations! 🎉  You've embarked on a journey to unlock the full potential of SQLite3 in your Node.js applications. Armed with an understanding of its powerful methods, you're equipped to tackle complex database tasks with confidence. So go ahead, leverage the magic of SQLite3!💻✨&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>sql</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding Redux: Solving State Management chaos</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Sun, 03 Mar 2024 12:36:33 +0000</pubDate>
      <link>https://dev.to/margish288/understanding-redux-solving-state-management-chaos-84d</link>
      <guid>https://dev.to/margish288/understanding-redux-solving-state-management-chaos-84d</guid>
      <description>&lt;p&gt;Hello folks !!! Are you tired of managing the state of your React application and finding it complex to handle? &lt;br&gt;
If so, you're not alone. Many developers face challenges when it comes to managing state in larger React applications. Let's dive into a common problem and explore how Redux can come to the rescue.💪🏻😁&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem: State Management in React&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you're building a simple to-do list application in React. You start off by creating components for adding, deleting, and displaying tasks. Initially, managing the state seems manageable. You might use useState hooks to handle the state within individual components.&lt;/p&gt;

&lt;p&gt;However, as your application grows, passing state and props down multiple levels of components becomes messy. You find yourself lifting state up to common ancestors or resorting to complex prop drilling. As a result, your code becomes harder to maintain, and debugging becomes a nightmare!🥲&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introducing Redux&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here Redux comes into picture, Redux is a predictable state container for JavaScript apps, especially useful for managing state in large and complex applications. It provides a centralized store to manage the entire state of your application, making state management more predictable and easier to debug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Refactoring with Redux&lt;/strong&gt;&lt;br&gt;
Let's see how Redux can solve our state management woes in our to-do list application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Setting Up Redux&lt;/strong&gt;&lt;br&gt;
First, install Redux and React-Redux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install redux react-redux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Creating the Store&lt;/strong&gt;&lt;br&gt;
Create a Redux store to hold the state of our application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// store.js
import { createStore } from 'redux';
import rootReducer from './reducers';

const store = createStore(rootReducer);

export default store;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Defining Actions and Reducers&lt;/strong&gt;&lt;br&gt;
Define actions to describe state changes and reducers to specify how those actions transform the state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// actions.js
export const ADD_TODO = 'ADD_TODO';

export const addTodo = (text) =&amp;gt; ({
  type: ADD_TODO,
  payload: {
    text,
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// reducers.js
import { ADD_TODO } from './actions';

const initialState = {
  todos: [],
};

const rootReducer = (state = initialState, action) =&amp;gt; {
  switch (action.type) {
    case ADD_TODO:
      return {
        ...state,
        todos: [...state.todos, action.payload],
      };
    default:
      return state;
  }
};

export default rootReducer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Connecting Components&lt;/strong&gt;&lt;br&gt;
Connect your components to the Redux store using React-Redux's connect function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// TodoList.js
import React from 'react';
import { connect } from 'react-redux';
import { addTodo } from './actions';

const TodoList = ({ todos, addTodo }) =&amp;gt; {
  const handleAddTodo = () =&amp;gt; {
    const text = prompt('Enter a new todo:');
    addTodo(text);
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;button onClick={handleAddTodo}&amp;gt;Add Todo&amp;lt;/button&amp;gt;
      &amp;lt;ul&amp;gt;
        {todos.map((todo, index) =&amp;gt; (
          &amp;lt;li key={index}&amp;gt;{todo.text}&amp;lt;/li&amp;gt;
        ))}
      &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

const mapStateToProps = (state) =&amp;gt; ({
  todos: state.todos,
});

const mapDispatchToProps = {
  addTodo,
};

export default connect(mapStateToProps, mapDispatchToProps)(TodoList);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
And there you have it, folks! With Redux by your side!!🫶🏻&lt;br&gt;
Redux provides a clear structure for managing application state, making it easier to reason about and debug. So next time you find yourself struggling with state management in React, consider giving Redux a try! ✨🔥&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>react</category>
      <category>redux</category>
    </item>
    <item>
      <title>Cook Up a Storm: Build a Recipe Finder App with React 🍱</title>
      <dc:creator>Margish Patel</dc:creator>
      <pubDate>Sun, 25 Feb 2024 18:06:38 +0000</pubDate>
      <link>https://dev.to/margish288/cook-up-a-storm-build-a-recipe-finder-app-with-react-5hc4</link>
      <guid>https://dev.to/margish288/cook-up-a-storm-build-a-recipe-finder-app-with-react-5hc4</guid>
      <description>&lt;p&gt;Hey there!👋🏻, culinary wizards and React aficionados! Are you tired of staring into your empty fridge wondering what to cook? Fear not, because we're about to embark on a delicious journey to build our very own Recipe Finder app using the magical powers of React. &lt;br&gt;
Get ready to spice up your coding skills and your kitchen adventures!🍲&lt;/p&gt;

&lt;p&gt;Ingredients for Success:&lt;br&gt;
Before we start cooking up some code, let's make sure we have all the necessary ingredients:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A dash of HTML, CSS, and JavaScript knowledge 🤓&lt;/li&gt;
&lt;li&gt;A pinch of React expertise (don't worry, we'll guide you through!😎)&lt;/li&gt;
&lt;li&gt;A dollop of creativity and a sprinkle of humor (optional, but highly recommended🤪)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Setting Up Our Kitchen:&lt;br&gt;
First things first, let's set up our development environment. Fire up your terminal and run the following commands to create a new React app!🔥:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app recipe-finder
cd recipe-finder
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that our kitchen is preheating, let's add some flavor with Tailwind CSS. Run this command to install Tailwind CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install tailwindcss@latest postcss-cli autoprefixer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Gathering Ingredients:&lt;br&gt;
Next up, we need to gather our ingredients. We'll be using the Spoonacular API to fetch delicious recipes. Head over to their website, sign up for a free account, and grab your API key. Now, let's add some Axios to our project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install axios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cooking Up the Recipe Finder:&lt;br&gt;
Now comes the fun part – cooking up our Recipe Finder app! Open up &lt;code&gt;src/App.js&lt;/code&gt; and let's get cooking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState, useEffect } from 'react';
import axios from 'axios';

const App = () =&amp;gt; {
  const [query, setQuery] = useState('');
  const [recipes, setRecipes] = useState([]);

  useEffect(() =&amp;gt; {
    const fetchRecipes = async () =&amp;gt; {
      try {
        const response = await axios.get(
          `https://api.spoonacular.com/recipes/complexSearch?apiKey=YOUR_API_KEY&amp;amp;query=${query}&amp;amp;number=10`
        );
        setRecipes(response.data.results);
      } catch (error) {
        console.error('Error fetching recipes:', error);
      }
    };

    if (query) {
      fetchRecipes();
    }
  }, [query]);

  const handleChange = (event) =&amp;gt; {
    setQuery(event.target.value);
  };

  return (
    &amp;lt;div className="container mx-auto mt-8"&amp;gt;
      &amp;lt;h1 className="text-3xl font-bold mb-4 text-center"&amp;gt;Recipe Finder&amp;lt;/h1&amp;gt;
      &amp;lt;div className="flex justify-center mb-8"&amp;gt;
        &amp;lt;input
          type="text"
          placeholder="Enter ingredients..."
          className="border rounded-l py-2 px-4 focus:outline-none"
          value={query}
          onChange={handleChange}
        /&amp;gt;
        &amp;lt;button className="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-r focus:outline-none"&amp;gt;
          Search
        &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8"&amp;gt;
        {recipes.map((recipe) =&amp;gt; (
          &amp;lt;div key={recipe.id} className="border rounded p-4 shadow-md"&amp;gt;
            &amp;lt;img
              src={recipe.image}
              alt={recipe.title}
              className="w-full h-48 object-cover mb-4"
            /&amp;gt;
            &amp;lt;h2 className="text-xl font-bold mb-2"&amp;gt;{recipe.title}&amp;lt;/h2&amp;gt;
            &amp;lt;p className="text-gray-700"&amp;gt;{recipe.summary}&amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;
        ))}
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding Some Spice with Tailwind CSS 🫕:&lt;br&gt;
Our Recipe Finder app is looking a bit bland, so let's add some spice with Tailwind CSS! Open up &lt;code&gt;src/index.css&lt;/code&gt; and replace its content with the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@tailwind base;
@tailwind components;
@tailwind utilities;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conclusion:&lt;br&gt;
Voilà! We've whipped up a tasty Recipe Finder app using React and spiced it up with Tailwind CSS. Now you can search for mouthwatering recipes to satisfy your cravings and impress your friends with your coding skills. &lt;br&gt;
Keep on cooking, coding, and having fun – bon appétit! 🍽️🚀&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
