<?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: Shaik Dawood</title>
    <description>The latest articles on DEV Community by Shaik Dawood (@dawoodxp97).</description>
    <link>https://dev.to/dawoodxp97</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%2F674956%2Fbeea1388-afd0-46dc-8366-2e3ac00cd849.jpg</url>
      <title>DEV Community: Shaik Dawood</title>
      <link>https://dev.to/dawoodxp97</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dawoodxp97"/>
    <language>en</language>
    <item>
      <title>Post 5: 🚀 From Slow Load to Lightning Speed: Quantifying Our React Performance Wins!</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Fri, 18 Apr 2025 17:26:23 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/post-5-from-slow-load-to-lightning-speed-quantifying-our-react-performance-wins-1ngm</link>
      <guid>https://dev.to/dawoodxp97/post-5-from-slow-load-to-lightning-speed-quantifying-our-react-performance-wins-1ngm</guid>
      <description>&lt;p&gt;Hey Devs! 👋&lt;/p&gt;

&lt;p&gt;This is the final post in our series on optimising React applications, and it's time to reveal the juicy results! We've been hard at work, and the performance improvements are pretty dramatic. Let's dive into the numbers and see how much faster our app has become.&lt;/p&gt;

&lt;p&gt;**&lt;br&gt;
📊 The Results and Impact: Quantifying a 70% Faster Load and 80% Quicker Build**&lt;/p&gt;

&lt;p&gt;We started with a set of initial performance metrics, and after implementing code splitting, lazy loading, and caching strategies, the difference is night and day.&lt;/p&gt;

&lt;p&gt;Here's a quick recap of what we set out to improve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Page Load Time:&lt;/strong&gt; How long it takes for users to see and interact with our app. ⏳&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React Build Time:&lt;/strong&gt; How long it takes for us, as developers, to build the app. 🛠️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;📈 Performance Metrics Comparison&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fnqn38ltoouo7he3j9v2v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fnqn38ltoouo7he3j9v2v.png" alt="metrics" width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚡️ Page Load Time: A User's Delight&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We've achieved an approximate ~70% reduction in page load time! 🚀 To measure this, we used a combination of browser developer tools and performance testing tools. This improvement means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lower bounce rates:&lt;/strong&gt; Users are less likely to leave a site that loads quickly. 📉&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Increased conversion rates:&lt;/strong&gt; A faster site improves user experience, making them more likely to complete desired actions. ✅&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Happier users:&lt;/strong&gt; Nobody likes waiting for a slow website! 😊&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A faster loading time translates directly to a better user experience and improved business metrics. It's a win-win! 🏆&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚙️ React Build Time: A Developer's Dream&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our React build time has been slashed by approximately 80%! 🤯 We measured this using our build tools, and the impact on our development workflow is significant:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster iteration cycles: We can see the results of our code changes much more quickly. ⏩&lt;/li&gt;
&lt;li&gt;More frequent deployments: Shorter build times enable us to deploy updates more often. 🚀&lt;/li&gt;
&lt;li&gt;Reduced CI/CD pipeline duration: Our overall software delivery process is now more efficient. ⏱️&lt;/li&gt;
&lt;li&gt;More productive developers: Less time waiting for builds means more time for coding! 🧑‍💻&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🛠️ Key Tools and Technologies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To achieve these gains, we leveraged several key tools and technologies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CRACO: To customize our Create React App configuration. ⚙️&lt;/li&gt;
&lt;li&gt;webpack: For optimizing our JavaScript modules. 📦&lt;/li&gt;
&lt;li&gt;React's lazy loading: To load components on demand. ⚛️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🎉 Conclusion: A Faster Future for Our App&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our performance optimisation journey has been a resounding success. We've significantly improved both the application's performance and our development team's efficiency. By focusing on key areas like code splitting, lazy loading, and caching, we've created a faster, more enjoyable experience for our users and a more efficient workflow for our developers.&lt;/p&gt;

&lt;p&gt;Now it's your turn! Share your own performance optimisation experiences and ask any questions you have in the comments below. Let's make the web a faster place, one React app at a time! 🚀✨&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>react</category>
      <category>webpack</category>
      <category>craco</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Post 4: Caching and Cache Busting - Ensuring a Smooth User Experience:</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Fri, 18 Apr 2025 17:06:41 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/post-4-caching-and-cache-busting-ensuring-a-smooth-user-experience-52cl</link>
      <guid>https://dev.to/dawoodxp97/post-4-caching-and-cache-busting-ensuring-a-smooth-user-experience-52cl</guid>
      <description>&lt;p&gt;Hello Devs! 👋&lt;/p&gt;

&lt;p&gt;Welcome to the fourth post in our series, where we'll dive into the crucial world of caching and &lt;strong&gt;cache busting&lt;/strong&gt;. These techniques are essential for delivering a consistently fast ⚡️ and reliable user experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Browser Caching: The Speed Booster 🏎️&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Browser caching is like giving your users' browsers a super-short-term memory. It stores copies of static assets (think JavaScript, CSS, and images 🖼️) locally on their computers.&lt;/p&gt;

&lt;p&gt;Why is this awesome? 🤔 When a user revisits your application, the browser can grab these assets from its local cache instead of downloading them again from your server. This results in significantly faster load times for those return visits.  Think of it as giving your users a VIP pass 🎫 to your site!&lt;/p&gt;

&lt;p&gt;Effective use of browser caching is &lt;strong&gt;key&lt;/strong&gt; 🔑 to improving the perceived performance of web applications, especially for those loyal, returning users. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Cache Challenge: When Updates Go Missing 🕵️‍♂️&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Here's the catch: what happens when you update your application and deploy new versions of those static assets? If the browser is still using the old cached versions, users won't see the latest and greatest changes. This can lead to inconsistencies, errors, and a generally confusing experience.  Imagine releasing a hotfix 🔥, but no one sees it! 😱&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cache Busting to the Rescue! 🦸&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;cache busting&lt;/strong&gt; comes in.  It's a set of techniques we use to make sure the browser fetches the new versions of assets when they're updated, while still taking advantage of caching for the assets that haven't changed.  It's like giving the browser a gentle nudge 😉 to update its memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Our Weapon of Choice: Filename Hashing 💥&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;One of the most common and effective cache busting strategies is to incorporate hashing into the names of our code chunks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How it works: We include a hash of the file's content in its name.&lt;/li&gt;
&lt;li&gt;The magic: If the file's content changes, the hash changes, and therefore the filename changes.&lt;/li&gt;
&lt;li&gt;The result: The browser sees it as a new file and downloads it. If the content doesn't change, the filename stays the same, and the browser uses the cached version.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows us to cache files indefinitely, because the filename will only change when the content changes.  It's like having a self-updating memo! 📝&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How we did it:&lt;/strong&gt; In our project, we added hashing to the chunk names using webpack configuration within CRACO.  Here's a simplified example of the kind of modification we made:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// craco.config.js
module.exports = {
  webpack: {
    configure: (webpackConfig) =&amp;gt; {
      webpackConfig.output.filename = 'static/js/[name].[contenthash:8].js'; // Added contenthash
      webpackConfig.output.chunkFilename = 'static/js/[name].[contenthash:8].chunk.js'; // Added contenthash
      // ... other webpack configurations
      return webpackConfig;
    },
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;code&gt;[contenthash:8]&lt;/code&gt; adds an 8-character hash to the filename.  When the file content changes, the hash, and thus the filename, will be different.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Beyond Hashing: Other Cache Busting Techniques 🛠️&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While filename hashing is powerful, there are other techniques, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Versioning:&lt;/strong&gt; Adding a version number to the asset URL (e.g., &lt;code&gt;style.css?v=1.2&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query parameters:&lt;/strong&gt; Appending a unique query parameter to the asset URL (e.g., &lt;code&gt;script.js?t=1678886400&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Our Project's Approach:&lt;/strong&gt; We implemented filename hashing in our project to address chunk loading errors.  This approach provided the most robust and automated solution, ensuring that users always get the correct version of our code.  We found it to be less error-prone than manual versioning or query parameter manipulation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling the Unexpected: Chunk Loading Errors 😬&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Even with the best cache busting, sometimes things can go wrong.  Chunk loading errors can still occur due to network issues, incomplete deployments, or other unforeseen circumstances.&lt;/p&gt;

&lt;p&gt;To handle these situations gracefully, we implemented strategies such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retry mechanisms: Automatically retrying to load the chunk after a delay.&lt;/li&gt;
&lt;li&gt;Fallback UI: Displaying a user-friendly message or a simplified version of the application if a chunk fails to load.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A robust error handling strategy ensures that your application remains resilient, even when things don't go as planned.  Think of it as having a backup plan 🛡️ in place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Dynamic Duo: Caching and Cache Busting Together 🤝&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Caching and cache busting work together to give your users the best of both worlds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast initial load times: Caching ensures that static assets are loaded quickly on subsequent visits.&lt;/li&gt;
&lt;li&gt;Up-to-date content: Cache busting guarantees that users always see the latest version of your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By implementing these techniques effectively, you can optimize your application's performance, improve user satisfaction, and create a truly seamless and up-to-date user experience.  It's a win-win! 🎉&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Browser caching speeds up repeat visits.&lt;/li&gt;
&lt;li&gt;Cache busting ensures users get the latest updates.&lt;/li&gt;
&lt;li&gt;Filename hashing is a powerful cache busting technique.&lt;/li&gt;
&lt;li&gt;Robust error handling is crucial for a resilient application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this post has helped you understand the importance of caching and cache busting. Let me know if you have any questions or want to share your own caching strategies in the comments below! 👇&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀💻&lt;/p&gt;

</description>
      <category>react</category>
      <category>webpack</category>
      <category>craco</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Post 3: Strategic Lazy Loading in React - Naming and Optimising Chunks</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Fri, 18 Apr 2025 16:35:44 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/post-3-strategic-lazy-loading-in-react-naming-and-optimising-chunks-5hi7</link>
      <guid>https://dev.to/dawoodxp97/post-3-strategic-lazy-loading-in-react-naming-and-optimising-chunks-5hi7</guid>
      <description>&lt;p&gt;Hey Devs! 👋&lt;/p&gt;

&lt;p&gt;Welcome to the third post of our blog series on &lt;em&gt;Optimising React applications!&lt;/em&gt; Today, we're diving deep into a powerful technique: Lazy Loading. This is a game-changer for performance, so buckle up! 🏎️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Lazy Loading?&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Imagine your app as a big house 🏠. You don't need to load everything at once, right? Lazy loading is like only loading the furniture when you enter a specific room. In React, it means loading components only when they're actually needed. This is super useful for components that aren't immediately visible, like those in different routes or behind user interactions (think modals or tabs). &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is this important? 🤔&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Faster Initial Load:&lt;/strong&gt; Smaller initial bundle = quicker first paint. 🎨&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved User Experience:&lt;/strong&gt; Users can start interacting with your app sooner. 🤩&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduced Overhead:&lt;/strong&gt; Less code to process upfront. 🧹 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;React.lazy() and  to the Rescue!&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;React provides two awesome tools for lazy loading: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React.lazy(): This function lets you dynamically import components. Think of it as saying, "Hey React, load this component later when I need it." ⏳&lt;/li&gt;
&lt;li&gt;: This component lets you show a fallback UI (like a loading spinner 🌀) while the lazy-loaded component is being fetched. It prevents your app from freezing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a simplified example:&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, { Suspense } from 'react';

const MyLazyComponent = React.lazy(() =&amp;gt; import('./MyComponent'));

function MyComponent() {
  return (
    &amp;lt;Suspense fallback={&amp;lt;div&amp;gt;Loading... ⏳&amp;lt;/div&amp;gt;}&amp;gt;
      &amp;lt;MyLazyComponent /&amp;gt;
    &amp;lt;/Suspense&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Naming Your Chunks: Why It Matters 🏷️&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;When you lazy load, webpack (or your bundler) creates separate "chunks" of code. By default, these chunks have generic names. But, giving them custom names is super helpful! &lt;/p&gt;

&lt;p&gt;Why ?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better Organization: Makes your code easier to manage. 🗂️&lt;/li&gt;
&lt;li&gt;Easier Debugging: You can quickly identify which chunk belongs to which component in your browser's network tab. 🕵️‍♀️&lt;/li&gt;
&lt;li&gt;Improved Analysis: Tools like webpack-bundle-analyzer become much more useful. 📊 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to Name Your Chunks&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;You can use "&lt;em&gt;magic comments&lt;/em&gt;" within your dynamic imports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const MyLazyComponent = React.lazy(() =&amp;gt;
  import(/* webpackChunkName: "my-custom-component" */ './MyComponent')
);

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

&lt;/div&gt;



&lt;p&gt;In this example, the lazy-loaded chunk will be named "my-custom-component". 🎉 &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lazy Loading Strategies: Route vs. Component&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;There are two main strategies: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Route-Based Splitting: Lazy load components for different routes. This is great for multi-page applications. 🗺️&lt;/li&gt;
&lt;li&gt;Component-Based Splitting: Lazy load individual components within a route (e.g., a large modal or a tab). This is useful for optimizing single-page applications. 🧩&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advanced Optimisation: Preloading and Prefetching&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For even more speed, consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preloading: Tells the browser to download a resource as soon as possible during the page load.&lt;/li&gt;
&lt;li&gt;Prefetching: Tells the browser that a resource might be needed in the future. &lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Conclusion: Faster Apps with Smarter Loading!&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Strategic lazy loading, especially with custom chunk names, is a powerful way to significantly reduce page load times and improve the overall user experience. By loading code only when needed, you create a faster, more efficient application. 🚀&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use React.lazy() to dynamically import components.&lt;/li&gt;
&lt;li&gt;Use  to provide a fallback UI.&lt;/li&gt;
&lt;li&gt;Use "magic comments" to name your chunks.&lt;/li&gt;
&lt;li&gt;Choose the right lazy loading strategy (route-based or component-based).&lt;/li&gt;
&lt;li&gt;Consider preloading and prefetching for extra performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy coding! 👨‍💻👩‍💻&lt;/p&gt;

</description>
      <category>react</category>
      <category>webpack</category>
      <category>craco</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Post 2: Mastering Code Splitting with Webpack and CRACO - A Deep Dive:</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Fri, 18 Apr 2025 16:14:12 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/post-2-mastering-code-splitting-with-webpack-and-craco-a-deep-dive-djf</link>
      <guid>https://dev.to/dawoodxp97/post-2-mastering-code-splitting-with-webpack-and-craco-a-deep-dive-djf</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Hey Devs! 👋 Welcome back to our series on optimizing your React apps. In this second post, we're diving deep into a crucial performance-enhancing technique: &lt;strong&gt;Code Splitting.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is Code Splitting? 🤔&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you're loading a huge website. 🐌 Everything loads at once, even the parts you don't see immediately. That's inefficient, right? Code splitting solves this!&lt;/p&gt;

&lt;p&gt;It's the process of breaking down your application's code into smaller chunks. 📦 These chunks are then loaded on demand, only when the user needs them. This leads to: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🚀 Faster initial load times.&lt;/li&gt;
&lt;li&gt;⚡ Improved performance.&lt;/li&gt;
&lt;li&gt;📱 Reduced resource consumption. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of it like ordering pizza 🍕 slice by slice, instead of getting the whole pie at once! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Webpack and CRACO: The Dynamic Duo 🦸‍♂️🦸&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Under the hood, Create React App (CRA) uses Webpack to bundle your code. Webpack takes all your JavaScript, CSS, and assets and transforms them into optimised bundles for the browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CRA provides a default Webpack configuration, which is great for getting started. But what if you want to customise it? That's where *&lt;em&gt;CRACO (Create React App Configuration Override) *&lt;/em&gt; comes in! 🛠️&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CRACO lets you tweak Webpack's configuration without ejecting from CRA. This is a game-changer! 🤩 It gives you the power to implement advanced techniques like code splitting.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Splitting &lt;code&gt;node_modules&lt;/code&gt;: A Performance Boost 🚀&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the most effective code-splitting strategies is to split your node_modules directory. 📦 This directory often contains a ton of third-party libraries. Bundling them all into one massive file can significantly slow down your initial load time. 🐢&lt;/p&gt;

&lt;p&gt;By splitting &lt;code&gt;node_modules&lt;/code&gt; into separate &lt;strong&gt;vendor chunks&lt;/strong&gt;, you achieve: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Improved caching: Browsers can cache these less frequently changing dependencies separately.&lt;/li&gt;
&lt;li&gt;📉 Reduced main bundle size: The initial download is smaller and faster.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a simplified example of how you might configure this in your &lt;code&gt;craco.config.js&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fv4leggsfo5ceymh4vqps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fv4leggsfo5ceymh4vqps.png" alt="craco file" width="800" height="1205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We're modifying the splitChunks configuration in Webpack.&lt;/li&gt;
&lt;li&gt;The cacheGroups option lets us define how chunks are created.&lt;/li&gt;
&lt;li&gt;We create a vendor chunk that includes modules from node_modules.&lt;/li&gt;
&lt;li&gt;We also create a common chunk for modules used in multiple places.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;Important Note: *&lt;/em&gt; This is a simplified example.  Webpack configuration can be complex, and the optimal setup will depend on your specific project.  Always test thoroughly!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build Time Considerations ⏱️&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keep in mind that code splitting might slightly increase your initial build time. 👷‍♀️ This is because Webpack has to do more work to create multiple bundles.&lt;/p&gt;

&lt;p&gt;However, the long-term benefits of improved caching and faster initial load times usually outweigh this initial trade-off. ⚖️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion: Split It Up! 🎉&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Splitting your &lt;code&gt;node_modules&lt;/code&gt; and other parts of your code is a powerful way to optimise your React applications. 🚀 By using Webpack and CRACO, you can effectively implement code splitting and deliver a faster, more efficient experience to your users. 💯&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code splitting improves performance by loading code on demand.&lt;/li&gt;
&lt;li&gt;Webpack bundles your code, and CRACO lets you customize its configuration.&lt;/li&gt;
&lt;li&gt;Splitting node_modules enhances caching and reduces initial load time.&lt;/li&gt;
&lt;li&gt;Analyze your bundles with tools like webpack-bundle-analyzer.&lt;/li&gt;
&lt;li&gt;Be aware of potential build time increases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy coding! 💻&lt;/p&gt;

</description>
      <category>react</category>
      <category>webpack</category>
      <category>craco</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Post 1: The Performance Optimisation Journey - Setting the Stage with CRACO:</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Fri, 18 Apr 2025 15:49:03 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/post-1-the-performance-optimisation-journey-setting-the-stage-with-craco-3dh2</link>
      <guid>https://dev.to/dawoodxp97/post-1-the-performance-optimisation-journey-setting-the-stage-with-craco-3dh2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In today's fast-paced digital landscape, application performance is paramount 🚀. A sluggish application can lead to frustrated users 😡, decreased engagement 📉, and ultimately, a negative impact on business outcomes 💸. Similarly, long build times can significantly hinder developer productivity 👨‍💻 and slow down the entire development lifecycle ⏳.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This This blog post is the first in a series that will delve into how we tackled performance challenges in our React application ⚛️, focusing on improving both page load times ⏱️ and build durations 🛠️. We'll explore how we used CRACO ⚙️ to customise our Create React App (CRA) configuration, and the strategies we employed to achieve significant performance gains 💪.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Performance Challenge&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;       We began with an application that, while functional, suffered from performance bottlenecks 😫. Users experienced slow page load times 🐌, leading to a less-than-ideal user experience 😞. Studies have shown that a large percentage of users abandon a website if it takes more than a few seconds to load ⏳. Beyond the user-facing issues, our development team was also grappling with prolonged build times 🏗️. These extended builds slowed down our iteration cycle 🔄, making it more time-consuming to deploy updates and new features 🚀.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Performance Matters&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The importance of optimal performance cannot be overstated 💯. For end-users, a fast and responsive application translates to a smooth and enjoyable experience ✨. Faster loading times lead to increased user engagement 📈, higher conversion rates 💹, and improved user satisfaction 😊. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For developers, efficient build times are crucial for maintaining productivity and agility ⚡. Shorter builds mean faster feedback loops 🔄, quicker deployments 🚀, and reduced development costs 💸. This allows teams to iterate more rapidly 🏃‍♂️, respond to user needs more effectively 🎯, and deliver value more quickly 🏆. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Enter CRACO: Customising CRA Without Ejecting (&lt;a href="https://craco.js.org/" rel="noopener noreferrer"&gt;https://craco.js.org/&lt;/a&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create React App (CRA) provides a fantastic foundation for building React applications ⚛️, offering a pre-configured build setup that simplifies development 😌. However, the default configuration can sometimes be limiting when it comes to performance optimization ⚙️. While CRA is great, many teams, including ours, prefer to avoid "ejecting" from CRA 🙅‍♂️. Ejecting provides full control over the configuration, but it also means losing the benefits of CRA's managed build process and automatic updates 📦. We wanted a solution that would allow us to customise the configuration without sacrificing these advantages 💡.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This is where CRACO (Create React App Configuration Override) comes in ✨. CRACO allows us to customise the underlying Webpack configuration ⚙️ and other build settings of a CRA application without ejecting 🥳. This approach provides the flexibility we need to optimise performance 💪, while still allowing us to benefit from CRA's ease of use and ongoing updates 🔄. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why CRACO?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We chose CRACO over other options, such as ejecting from CRA or using other configuration management tools, for several key reasons:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Maintainability:&lt;/em&gt; CRACO allows us to customize the configuration while still benefiting from CRA's updates and improvements 🔄. Ejecting would have placed the burden of maintaining the entire build process on our team 👨‍🔧.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Simplicity:&lt;/em&gt; CRACO is relatively easy to set up and use 😌. It provides a clean and intuitive way to modify the configuration without requiring deep knowledge of webpack 🧠.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Flexibility:&lt;/em&gt; CRACO provides the necessary flexibility to customize Webpack and other build settings to address our specific performance needs ⚙️.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CRACO allowed us to fine-tune our build process for optimal performance 🚀, addressing both page load times ⏱️ and build durations 🏗️, without sacrificing the benefits of the CRA ecosystem ⚛️. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Looking Ahead&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This post has set the stage for our performance optimisation journey 🗺️. We've outlined the challenges we faced 😫, explained the importance of performance 💯, and introduced CRACO as our tool of choice ⚙️. In the upcoming posts in this series, we will dive into the specific optimisation techniques we implemented, including:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Code splitting and lazy loading ✂️&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bundle analysis and optimization 📦&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Caching strategies 🗄️&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build process optimizations 🛠️&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;We'll share our experiences, code examples 💻, and the results we achieved 💪, providing a practical guide for improving the performance of your own React applications ⚛️. Stay tuned! 📣&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>webpack</category>
      <category>craco</category>
      <category>productivity</category>
    </item>
    <item>
      <title>🔥JavaScript Interview Questions for Machine Coding rounds⚡</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Wed, 11 Aug 2021 11:25:27 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/javascript-interview-questions-for-machine-coding-rounds-23h4</link>
      <guid>https://dev.to/dawoodxp97/javascript-interview-questions-for-machine-coding-rounds-23h4</guid>
      <description>&lt;p&gt;Hello everyone,👋&lt;/p&gt;

&lt;p&gt;In this article we'll discuss about JavaScript Interview questions that will be asked in the Machine Coding Rounds or Code Assignment Rounds.&lt;/p&gt;

&lt;p&gt;🔥 I've listed out some of the questions which may ask in the UI interviews. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Comments Widget:&lt;/strong&gt;
👉 We need to develop a comments widget with functionality as shown below:

&lt;ul&gt;
&lt;li&gt;Able to comment.&lt;/li&gt;
&lt;li&gt;Edit the comment.&lt;/li&gt;
&lt;li&gt;Delete the comment.&lt;/li&gt;
&lt;li&gt;Like the Comment.&lt;/li&gt;
&lt;li&gt;Nested Comments. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Todo App:&lt;/strong&gt;&lt;br&gt;
👉 We need to develop a Todo App with functionality as shown below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create, Edit, Delete Lists.&lt;/li&gt;
&lt;li&gt;DND (Drag and Drop Cards ) feature.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Food Ordering App:&lt;/strong&gt;&lt;br&gt;
👉 We need to develop a Food Ordering App with functionality as shown below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Able to display Restaurants information using an API or create a JSON.&lt;/li&gt;
&lt;li&gt;Display menu of Food Items.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  We'll discuss this questions one by one in this Blog only. Stay tuned for it.😎
&lt;/h3&gt;

&lt;p&gt;{ .....&lt;br&gt;
..&lt;br&gt;
... to be continued.&lt;br&gt;
}&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>coding</category>
      <category>interview</category>
    </item>
    <item>
      <title>🔥 Advanced JavaScript Concepts.😎</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Wed, 11 Aug 2021 11:19:09 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/advanced-javascript-concepts-198l</link>
      <guid>https://dev.to/dawoodxp97/advanced-javascript-concepts-198l</guid>
      <description>&lt;p&gt;Hello everyone,👋&lt;/p&gt;

&lt;p&gt;If you are new to JavaScript, it can be little bit of challenging to understand some core and Advance topics 🤷‍♂️. But don't worry keep your fingers crossed🤞 because in this article you'll get full information regarding Advanced JS Topics😁.&lt;/p&gt;

&lt;p&gt;⚡ 1. &lt;strong&gt;Closures:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;MDN Def:&lt;/strong&gt; A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment).&lt;/p&gt;

&lt;p&gt;Doesn't sound great to you???🤔 Don't worry. Stay tuned.🔥&lt;/p&gt;

&lt;p&gt;So, Basically a function bind together with its lexical environment or lexical scope is known as &lt;strong&gt;Closer&lt;/strong&gt;. Let's see what exactly is lexical scope.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U66q2is7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xtltz0ggv4sjgpdnbnh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U66q2is7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xtltz0ggv4sjgpdnbnh.png" alt="closure1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⚡The word lexical refers to the fact that lexical scoping uses the location where a variable is declared. Nested functions have access to variables declared in their outer scope.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ImxZKRFr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7ok1tij50m18gkbpt4c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ImxZKRFr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7ok1tij50m18gkbpt4c.png" alt="closure2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⚡ Running this code has exactly the same effect as the previous example of the x() function above.&lt;br&gt;
⚡ What's different (and interesting) is that the displayName() inner function is returned from the outer function before being executed. The reason is that functions in JavaScript form closures. A closure is the combination of a function and the lexical environment within which that function was declared.&lt;/p&gt;

&lt;p&gt;✅ Every closure has three scopes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Local Scope (Own scope).&lt;/li&gt;
&lt;li&gt;Outer Functions Scope.&lt;/li&gt;
&lt;li&gt;Global Scope.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ Let's say a function can access some variables of it's lexical environment or parent scope, the function actually remembers the reference of variable but it's value. &lt;/p&gt;

&lt;p&gt;Let's look at the code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q2b7SF60--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8joldv7l384qd4e3qqj0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q2b7SF60--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8joldv7l384qd4e3qqj0.png" alt="closure3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you might have a bit understanding of Closures right.😎&lt;/p&gt;

&lt;p&gt;✅ let's see some of uses of Closures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Module design pattern.&lt;/li&gt;
&lt;li&gt;Currying.&lt;/li&gt;
&lt;li&gt;Functions like once.&lt;/li&gt;
&lt;li&gt;Memoize. &lt;/li&gt;
&lt;li&gt;Maintaining state in Async World.&lt;/li&gt;
&lt;li&gt;setTimeouts.&lt;/li&gt;
&lt;li&gt;Iterators.&lt;/li&gt;
&lt;li&gt;and so on.......!.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;{ .....&lt;br&gt;
..&lt;br&gt;
... to be continued.&lt;br&gt;
}&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>🔥 React Hooks.😎</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Wed, 11 Aug 2021 07:23:38 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/react-hooks-5eop</link>
      <guid>https://dev.to/dawoodxp97/react-hooks-5eop</guid>
      <description>&lt;p&gt;Hello everyone,👋&lt;/p&gt;

&lt;p&gt;In this article we'll discuss about React Hooks. Before the release of React Hooks, its functional components were a bit limited in usage. I mean, when it comes to working with State, context API, and some Lifecycle methods there was nothing we could do.&lt;br&gt;
But, starting from React 16.8, we have a lot more flexibility to reuse an existing piece of code.&lt;/p&gt;

&lt;p&gt;✨Hooks are the new feature introduced in the React 16.8 version. It allows you to use state and other React features without writing a class. Hooks are the functions which "hook into" React state and lifecycle features from function components.&lt;/p&gt;

&lt;p&gt;✨ Hooks don't work inside class components. They let you use React without the class.&lt;/p&gt;

&lt;p&gt;✨ Hooks will reduce your component size significantly and have many other benefits.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 3 Rules of using Hooks:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You can use hooks only inside a &lt;strong&gt;function components&lt;/strong&gt;. Not inside class components because classes already have features what hooks enable you to do.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You should call hooks only at the &lt;strong&gt;Top Level&lt;/strong&gt; of the function. Don't call Hooks inside loops, conditions, or nested functions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There is just one other valid place to call Hooks is your &lt;strong&gt;Custom Hooks&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's get Started with the top most great React Hooks.🔥&lt;/p&gt;

&lt;p&gt;⚡ 1. &lt;strong&gt;useState( ) Hook:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 The useState( ) hook lets you add react state to function components. So function components are &lt;strong&gt;no longer&lt;/strong&gt; stateless.&lt;/p&gt;

&lt;p&gt;👉 The useState( ) is the most commonly used Hook that allows you to &lt;strong&gt;create, read and update&lt;/strong&gt; simple internal state variables in your react function component.&lt;/p&gt;

&lt;p&gt;Sounds great right, Stay tuned then.😎&lt;/p&gt;

&lt;p&gt;🤷‍♂️ Why useState( ) is not named as createState( ) ?🤔&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Create&lt;/strong&gt; would imply that the state was created for the first time when the component renders. But the useState( ) executes every time the function component re-renders.&lt;/p&gt;

&lt;p&gt;👉 During the subsequent re-renders, the useState( ) hook will give  us the &lt;strong&gt;Current State.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 So &lt;strong&gt;"use"&lt;/strong&gt;State( ) is appropriate name.&lt;/p&gt;

&lt;p&gt;Let's look at the syntax of &lt;strong&gt;useState( ):&lt;/strong&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%2F0i27cloa2u8pyyvzwqy5.png" 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%2F0i27cloa2u8pyyvzwqy5.png" alt="useState"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 useState hook always returns an array with 2 values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The State variable itself.&lt;/li&gt;
&lt;li&gt;A function to update the state variable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 If you use this state variable inside JSX, the component re-renders every time the value changes.&lt;/p&gt;

&lt;p&gt;👉 The &lt;strong&gt;setVariable&lt;/strong&gt; function is used to update the state variable whenever needed in the component.&lt;/p&gt;

&lt;p&gt;👉 The &lt;strong&gt;"setVariable"&lt;/strong&gt; name doesn't really matter. You can name it anything you want.&lt;/p&gt;

&lt;p&gt;Let's look at few examples of the useState( ):&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%2F1l3yr1p1z00857jbwapn.png" 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%2F1l3yr1p1z00857jbwapn.png" alt="examples of useState"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⚡ 2. &lt;strong&gt;useEffect( ) Hook:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 The Effect Hook lets you perform side effects in function components. If you’re familiar with React class lifecycle methods, you can think of &lt;strong&gt;useEffect&lt;/strong&gt; Hook as &lt;strong&gt;componentDidMount&lt;/strong&gt;, &lt;strong&gt;componentDidUpdate&lt;/strong&gt;, and &lt;strong&gt;componentWillUnmount&lt;/strong&gt; combined.&lt;/p&gt;

&lt;p&gt;👉 It is like a Functional programming concept, where we try to encapsulate side effects in other functions so that other Functions can stay pure/unaffected.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;useEffect&lt;/strong&gt; hook must declare inside the component (top-level, don't declare them in the block), it will give several advantages (Thanks to closure):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It will have accessibility to those data that are required to use in side effects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can also update the data later, based on the dependencies and changes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The syntax of Effect hook is below:&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%2Fsb3sa645fa36mmnsxqrs.png" 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%2Fsb3sa645fa36mmnsxqrs.png" alt="useEffect Syntax"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first argument in &lt;em&gt;useEffect&lt;/em&gt; is to give side effects function.&lt;/li&gt;
&lt;li&gt;The second argument is the dependencies array which gives instructions to &lt;em&gt;useEffect&lt;/em&gt; hook when to run and when to not. Let's see this more closely:

&lt;ul&gt;
&lt;li&gt;If you don't give dependences array, only pass the first argument, then &lt;em&gt;useEffect&lt;/em&gt; runs whenever your component renders/re-renders.&lt;/li&gt;
&lt;li&gt;If you give an empty dependences array, then &lt;em&gt;useEffect&lt;/em&gt; runs once(when your component renders the first time, after that, it will not run unless you refresh the page).&lt;/li&gt;
&lt;li&gt;If you give something in the dependencies array, then &lt;em&gt;useEffect&lt;/em&gt; will run once by default after the component finish rendering. After that, whenever the value of elements in the dependences array change, then &lt;em&gt;useEffect&lt;/em&gt; will run again. Example: [isItemHidden].&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;👉 Well, whenever your components finish rendering, useEffects run unless you specified dependencies in the dependencies array.&lt;/p&gt;

&lt;p&gt;🤷‍♂️ &lt;strong&gt;Why should we use useEffects( )?&lt;/strong&gt; 🤔&lt;/p&gt;

&lt;p&gt;There are several cases where you should consider useEffects. Some of them are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Suppose you are fetching some data online to display movie titles, ratings &amp;amp; you have used handler(Function with the synthetic event) or used inline Functions to get that data. So, what will happen is your component rendering will be stuck when the thread of execution reaches this point until you get the data from outside of the world.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By seeing the first point, we can move those side effects to the useEffect hook so that our components can load/render. After completing the rendering process, React Engine will fire the useEffect hook to run the side effects code and update the component data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We should useEffect, when your component depends on the outside world data, and we can not guarantee that data will come or not (maybe the server is down there). So, Instead of throwing errors and stop other components from being rendered, move them into useEffect hook.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you are using browser API (including Timer function, fetch API, local storage and for more browser API, refer to this: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API" rel="noopener noreferrer"&gt;MDN Browser API&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;🌈 &lt;strong&gt;Some use cases of React useEffect hook:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Always run whenever component renders/re-renders.&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%2Faccnnrp4iarrvg6rkg1h.png" 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%2Faccnnrp4iarrvg6rkg1h.png" alt="usecase1"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run once after that if component re-renders, then it will not run.&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%2Fqcnpsqytok5wmxffehub.png" 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%2Fqcnpsqytok5wmxffehub.png" alt="usecase2"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run once by default after that if prop values changes, then run.&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%2Flsynsti2ejohwmlzqxyi.png" 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%2Flsynsti2ejohwmlzqxyi.png" alt="usecase3"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run once by default after that if state changes than run.&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%2Fc9407rzaewb61dp7h8ga.png" 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%2Fc9407rzaewb61dp7h8ga.png" alt="usecase4"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚡ 3. &lt;strong&gt;useContext( ) Hook:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 To understand the useContext( ) hook properly, first we have to understand what "Context" stands for...🤔&lt;/p&gt;

&lt;p&gt;✨ &lt;strong&gt;Context&lt;/strong&gt; provides a way to pass data through the component tree without having to pass props down manually at every level. ✨&lt;/p&gt;

&lt;p&gt;👉 In a typical React application, we have components from Parent to children and grandchildren. Let's say we have to pass some data from parent component to grandchild component, to do that we need to pass the data from each and every component to the last component. This is known as prop drilling.&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%2Fishuge0z2wvf9rvpnepm.png" 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%2Fishuge0z2wvf9rvpnepm.png" alt="Props"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this one the data is passed top-down (parent to child) via props. But that method can be clumsy for certain data. &lt;/p&gt;

&lt;p&gt;👉 So to overcome that Context comes into the picture. The context provides a way to share values between components without having to explicitly pass a prop through every level of component tree.&lt;/p&gt;

&lt;p&gt;🤷‍♂️ &lt;strong&gt;When should we use Context ?&lt;/strong&gt; 🤔&lt;/p&gt;

&lt;p&gt;👉 If the data is supposed to use as "Globally" then we should use context. Basically, context is designed to share data that can be considered "global" for a tree of react components.&lt;/p&gt;

&lt;p&gt;🌈 So in order to apply the methods of context, we have React Context API.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;React.createContext:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&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%2Fjy3apmldr6occvcrt76p.png" 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%2Fjy3apmldr6occvcrt76p.png" alt="CreateContext"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 It is used to create a context object. When React renders a component that subscribes to this context object it will read the value of this context.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Context.Provider:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&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%2Fxf8bsmnofqamj1a3ndvn.png" 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%2Fxf8bsmnofqamj1a3ndvn.png" alt="context provider"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 Every Context object comes with a Provider React component that allows consuming components to subscribe to context changes.&lt;/p&gt;

&lt;p&gt;👉 Basically once we wrap our parent component with the context provider the parent component and as well as child component can access to the prop value given by the Context Provider using useContext( ) hook.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summarization of useContext: 🔥
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;👉 The &lt;strong&gt;useContext( )&lt;/strong&gt; hook is used to store the context for a React component through a context provider.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;👉 Wrap the provider to the component like below&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fnghxcf6aqv8fypl6wqlt.png" 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%2Fnghxcf6aqv8fypl6wqlt.png" alt="context"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;👉 Access the context like below inside myComponent&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%2Fdty2fzl78jchx4s7lscv.png" 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%2Fdty2fzl78jchx4s7lscv.png" alt="access Context"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;👉 The value of the context will be the value passed to the nearest parent provider.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;👉 When the nearest parent provider updates,  will get re-rendered with the latest context value.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  And Much More…🔥😎
&lt;/h2&gt;

&lt;p&gt;👉 There are other Hooks as well in React. Will try to continue it as series. Stay Tuned.&lt;/p&gt;

&lt;h3&gt;
  
  
  If you liked this post, please react and let me know what you think in the comments! See you in next Article. Goodbye.
&lt;/h3&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>hooks</category>
    </item>
    <item>
      <title>🔥EcmaScript 6 (2015 Edition) Top Features.🔥</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Wed, 11 Aug 2021 03:24:35 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/ecmascript-6-2015-edition-top-features-21ph</link>
      <guid>https://dev.to/dawoodxp97/ecmascript-6-2015-edition-top-features-21ph</guid>
      <description>&lt;p&gt;Hello everyone,👋&lt;br&gt;
In this article we'll list out the top features of EcmaScript6 (2015 Edition). ECMAScript was created to standardize JavaScript, and ES6 is the 6th version of ECMAScript, it was published in 2015, and is also known as ECMAScript 2015.&lt;/p&gt;

&lt;p&gt;Let's get Started with the top most great features of the ES6.🔥&lt;/p&gt;

&lt;p&gt;⚡ 1. &lt;strong&gt;Default Parameters in ES6:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Functions can now be defined with default parameters. Missing or undefined values are initialized with the default value.&lt;br&gt;
The syntax of Default Parameters in ES6 is below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X8Kfm1G_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgiih2blpbe6yp6d2pwa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X8Kfm1G_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgiih2blpbe6yp6d2pwa.png" alt="def params"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript, function parameters default to undefined. However, it's often useful to set a different default value. This is where default parameters can help.&lt;/p&gt;

&lt;p&gt;In the past, usually for setting defaults was to test parameter values in the function body and assign a value if they are undefined.&lt;/p&gt;

&lt;p&gt;Let's have a look at example below, if no value is provided for b when multiply is called, b's value would be undefined when evaluating a * b and multiply would return NaN.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hBoxL0UJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/350xskq8z26hn7qkqnj4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hBoxL0UJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/350xskq8z26hn7qkqnj4.png" alt="params"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To handle this situation the Default Parameters of ES6 comes into the picture. Checks in the function body are no longer necessary. Now, you can assign 1 as the default value for b in the function head.&lt;br&gt;
Have a look at example below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f9cpV1ac--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08rwk1j7fwo444naswai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f9cpV1ac--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08rwk1j7fwo444naswai.png" alt="params case"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 The default values can be more than just values, they can be expressions or functions.&lt;/p&gt;

&lt;p&gt;Let's move to another feature of ES6.&lt;/p&gt;

&lt;p&gt;⚡ 2. &lt;strong&gt;Template Literals in ES6:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Template literals make working with string so much easier than before. They're started with a back tick and can have variables inserted using ${variable}. So in ES5 we had to break the string like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iXAI7OhL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5h3psm7rercbvdkapg5g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iXAI7OhL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5h3psm7rercbvdkapg5g.png" alt="es5 back ticks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Luckily, in ES6 we can use a new syntax ${NAME} inside of the back-ticked string:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MRzEWVIG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mwlx56m2sydqema26gal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MRzEWVIG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mwlx56m2sydqema26gal.png" alt="template literals"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;😎This makes life far simpler and code easier to read. You can put anything inside of the curly braces: variables, equations, or function calls.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Expression Interpolation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In order to embed expressions within normal strings, usually we use the following syntax:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OaGmPDKm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk1wttwdswnzgvrfywsd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OaGmPDKm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk1wttwdswnzgvrfywsd.png" alt="exp int"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But now, with template literals, you are able to make use of the syntactic sugar, making substitutions like this more readable:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GgsbDyh4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdqijuzqiaqhx7njyghs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GgsbDyh4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdqijuzqiaqhx7njyghs.png" alt="exp iunt"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Multi-Line Strings:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another yummy syntactic sugar  is multi-line string. In ES5, we had to use one of these approaches:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3gCWcplM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6uxokh6pq697ruecij1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3gCWcplM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6uxokh6pq697ruecij1.png" alt="ml str"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While in ES6, simply utilize the backticks:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HTBOMyJG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4w1xap03knv7tv24ircl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HTBOMyJG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4w1xap03knv7tv24ircl.png" alt="es6 back ml"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⚡ 3. &lt;strong&gt;Destructuring in ES6:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Destructuring is the process of taking apart the array or object on the left hand side of the equal sign. The array or object can come from a variable, function or equation.&lt;br&gt;
Let's have a look at below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K7jPi-f1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mxq5b3v9uuptii154w85.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K7jPi-f1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mxq5b3v9uuptii154w85.png" alt="des es6"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With objects destructuring the keys of the object can be listed inside curly braces to extract that key-value pair.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fZ9_VCdR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iymczw348e6vp3qg906f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fZ9_VCdR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iymczw348e6vp3qg906f.png" alt="ds in es6"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes you want to extract the values but assign them to a new variable. This is done using a 'key: variable' pairing on the left of the equals sign.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hBtavED---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdcyn9kme5k25bd2l97e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hBtavED---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdcyn9kme5k25bd2l97e.png" alt="des"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another thing that object destructuring allows is assigning a value to multiple variables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0lRW5AIq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as6k148wwxw23td5tpr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0lRW5AIq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as6k148wwxw23td5tpr0.png" alt="desr es"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⚡ 4. &lt;strong&gt;Arrow Functions in ES6:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Arrow functions have 2 main ways: their structure and their 'this' binding.&lt;br&gt;
They can have a much simpler structure than traditional functions because they don't need the 'function' key word and they automatically return whatever is after the arrow.&lt;br&gt;
The fat arrows are amazing because they would make your this behave properly, i.e., this will have the same value as in the context of the function—it won’t mutate. The mutation typically happens each time you create a closure.&lt;/p&gt;

&lt;p&gt;Using arrows functions in ES6 allows us to stop using that = this or self = this or _this = this or .bind(this). For example, the following code in ES5 is weird:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---G_M2hk---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4921idffagv1xfhy16ba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---G_M2hk---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4921idffagv1xfhy16ba.png" alt="arr 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Luckily due to ES6 feature this code can be written as below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_Yzwpq-B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1in2b7fi57rw7kewv1o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_Yzwpq-B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1in2b7fi57rw7kewv1o.png" alt="arr 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 The parenthesis () are optional for single params in an arrow function signature. You need them when you use more than one param.&lt;/p&gt;

&lt;p&gt;👉 One of the most useful places for arrow functions is in array functions like .map, .forEach or .sort.&lt;/p&gt;

&lt;p&gt;⚡ 5. &lt;strong&gt;Spread Operator in ES6:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ES6 introduces the &lt;code&gt;...&lt;/code&gt; operator which is referred to as the spread operator. It has two main uses: spreading an array or object into a new array or object, and joining multiple parameters into an array. The first use case is the one you'll probably encounter most so well look at that first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Uo0-aKUr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uk2hv5ovolcslxjgx8hk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Uo0-aKUr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uk2hv5ovolcslxjgx8hk.png" alt="spread1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This can be very useful for passing in a set of variables to a function from an array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bN7rd8F8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6nyiww08ry3gtfo9srbn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bN7rd8F8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6nyiww08ry3gtfo9srbn.png" alt="spread2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An object can also be spread, inputting each of the key value pairs into the new object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0LekCdjO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9eaaq9vbhx4qp81dw3ja.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0LekCdjO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9eaaq9vbhx4qp81dw3ja.png" alt="spread3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Rest Syntax(Parameters):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rest syntax looks exactly like spread syntax. In a way, rest syntax is the opposite of spread syntax. Spread syntax "expands" an array into its elements, while rest syntax collects multiple elements and "condenses" them into a single element.&lt;/p&gt;

&lt;p&gt;⚡ 6. &lt;strong&gt;Number Literals:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ES5 code handled decimal and hexadecimal number formats well but octal form wasn't specified, and was actively disallowed in strict mode. ES6 has added a new format, adding an 'o' after the initial 0 to declare the number an octal. They've also added a binary format.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w3OOpbhe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4okid2a25whuv5dp06j8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w3OOpbhe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4okid2a25whuv5dp06j8.png" alt="num"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⚡ 7. &lt;strong&gt;The “let” and “const” keywords:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let and Const are different ways of creating variables. We all are very well familiar with the var keyword which is used to create variables. Right!? Although, you can still use var to create variable although, you are highly encouraged to use let and const instead.&lt;/p&gt;

&lt;p&gt;👉Let and const are different in terms of the use and scope.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8l3sm-ZG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/86ak6eay8ijxmepv0u6q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8l3sm-ZG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/86ak6eay8ijxmepv0u6q.png" alt="Let and const"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉Let is actually used for variable use where you need to reassign the value of variable but const is used when you don’t need to change its value once it is declared. Reassigning the value to the const type variable will trigger an error.&lt;/p&gt;

&lt;p&gt;👉Moreover, difference between let and var is function scoped while let is blocked scoped.&lt;/p&gt;

&lt;h2&gt;
  
  
  And Much More…🔥😎
&lt;/h2&gt;

&lt;p&gt;👉There is much, much more that ES6 offers us to make our code cleaner, shorter, easier to read and more robust.🔥&lt;/p&gt;

&lt;h3&gt;
  
  
  If you liked this post, please react and let me know what you think in the comments! See you in next Article. Goodbye.
&lt;/h3&gt;

</description>
      <category>javascript</category>
      <category>es6</category>
      <category>programming</category>
    </item>
    <item>
      <title>Asynchronous JavaScript 🔥😎</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Tue, 10 Aug 2021 18:05:47 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/asynchronous-javascript-5ded</link>
      <guid>https://dev.to/dawoodxp97/asynchronous-javascript-5ded</guid>
      <description>&lt;p&gt;Hello everyone,👋&lt;br&gt;
If you are new to JavaScript, it can be little bit of challenging to understand its async nature🤷‍♂️. But don't worry keep your fingers crossed🤞 because in this article you'll get full information regarding asynchronous JS😁.&lt;/p&gt;

&lt;p&gt;To understand asynchronous JavaScript, firstly we need to understand what is Synchronous JavaScript🤔. The term Synchronous defines the only one task can be done at a time. So in JavaScript, in a particular block of code the lines ate executed one by one. While each operation is being processed, nothing else can happens because the rendering is paused🥴. This happens because the JavaScript is a single threaded language, only one thing can happen at a time on single main thread and everything else is blocked until an operation completes.&lt;/p&gt;

&lt;p&gt;⚡So, in simple terms the Asynchronous JavaScript is &lt;strong&gt;Start something now and finish it later&lt;/strong&gt;. So it governs how we perform the tasks which takes some time to complete. Many Web API features now use asynchronous code to run, especially those that access or fetch some kind of resource from an external device, such as fetching a file from the network, accessing a database and returning data from it.&lt;/p&gt;

&lt;p&gt;Still confusing why we need Asynchronous ??🤐. Let's look at the following Image to get a clarity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EQEzBZGj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7sxvfw5ogszynsasufxy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EQEzBZGj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7sxvfw5ogszynsasufxy.png" alt="async"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alright folks, now we know that how asynchronous code works right. Let's head over to another topic.&lt;/p&gt;

&lt;p&gt;⚡&lt;strong&gt;HTTP Requests&lt;/strong&gt;: We generally used to make the HTTP requests to get the data from another server. We make these requests to API Endpoints.&lt;br&gt;
🌈Look at the following Image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Cm56pX8b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s73ssebo8lq5gp0ec0a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Cm56pX8b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s73ssebo8lq5gp0ec0a.jpg" alt="Http"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most of the data is grabbed in the JSON Format.&lt;br&gt;
Wondering how to make the HTTP request?. Observe the following code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uE215Gsd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkes3dnww1wxixwus5h4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uE215Gsd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkes3dnww1wxixwus5h4.png" alt="http req"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we got to know that how to make request right. But how do we access the response data?🤔. Well in our code we can track the progress of request using an Event Listener and a specific event called &lt;strong&gt;&lt;em&gt;readystatechange&lt;/em&gt;&lt;/strong&gt; . Let's implement that in our code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wiZqBXtU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2wq9ojo5cnzd1jc7jnvm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wiZqBXtU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2wq9ojo5cnzd1jc7jnvm.png" alt="http im"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So by using this code we can make a HTTP request.🤜🤛&lt;br&gt;
Sounds Overwhelming ?? 🤷‍♂️ Well hold on there's lot more to go.✌&lt;/p&gt;

&lt;p&gt;Let's move on to the next topic:&lt;/p&gt;

&lt;p&gt;⚡&lt;strong&gt;Callbacks&lt;/strong&gt;:&lt;br&gt;
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of task.🌈&lt;/p&gt;

&lt;p&gt;Let's look at the example code below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pnkDQmYG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2tm5ei2b1avyeqa3y8e0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pnkDQmYG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2tm5ei2b1avyeqa3y8e0.png" alt="callbacks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, that callbacks are often used to continue code execution after an asynchronous operation has completed — these are called &lt;em&gt;Asynchronous Callbacks&lt;/em&gt;. A good example is the callback functions executed inside a &lt;strong&gt;".then()"&lt;/strong&gt; block chained onto the end of a promise after that promise fulfills or rejects. This structure is used in many modern web APIs, such as &lt;strong&gt;"fetch()"&lt;/strong&gt;.&lt;br&gt;
⚡Definition of Async Callback: The Asynchronous Callbacks are the functions that are specified as arguments when calling a function which will start executing code in the background. The best example for Async Callback is the Second Parameter of the &lt;em&gt;.addEventListener&lt;/em&gt; .&lt;/p&gt;

&lt;p&gt;Let's deep dive into some more topics now.&lt;/p&gt;

&lt;p&gt;⚡&lt;strong&gt;Promises&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;👉Def: A Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason.&lt;br&gt;
Sounds tedious right?🥴. Well don't worry let's understand it in simple way.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⚡👉"Producing Code" is code that can take some time.&lt;/li&gt;
&lt;li&gt;⚡👉"Consuming Code" is code that must wait for the result.&lt;/li&gt;
&lt;li&gt;⚡⚡ A promise is a JavaScript object that links Producing code and consuming Code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So Technically a promise is simply an object in JavaScript. A promise is always in one of the three states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;➡️ &lt;strong&gt;pending:&lt;/strong&gt; which is initial state, neither fulfilled nor rejected&lt;/li&gt;
&lt;li&gt;➡️ &lt;strong&gt;fulfilled:&lt;/strong&gt; meaning that the operation completed successfully.&lt;/li&gt;
&lt;li&gt;➡️ &lt;strong&gt;rejected:&lt;/strong&gt; meaning that the operation failed.
So basically we cannot access the properties state and results, we must use promise method to handle promises.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How to implement that is shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yPClTHpT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8hs3fin2otah8rpiu7o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yPClTHpT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8hs3fin2otah8rpiu7o.png" alt="promise"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now why we need Promises?🤔&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Promises&lt;/strong&gt; help us to deal with asynchronous code in a far more simpler way compared to callbacks.&lt;br&gt;
Callback hell can be avoided with Promises.&lt;/p&gt;

&lt;p&gt;Look at the below image to get a idea about Promises.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ix_ASd-S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkx1aoopnxqbi41qqysl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ix_ASd-S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkx1aoopnxqbi41qqysl.png" alt="Promise"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's jump into another topic:&lt;/p&gt;

&lt;p&gt;⚡&lt;strong&gt;Async / Await&lt;/strong&gt;: Async and await make promises easier to write.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Async makes a function return a promise.&lt;/li&gt;
&lt;li&gt;Await makes a function wait for a promise.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The await keyword can only be used inside an Async Function. Async / await is another way of handling promises in JavaScript. One of the main advantage of using it is clean code.&lt;br&gt;
In general, we use .then().catch() to handle promises right, but now let's handle it using async / await. We can write using function statement or function expression. Both will be valid, only difference is use of anonymous function in function expression.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V-O1AG_T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dgskr51ul9f6winuzkvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V-O1AG_T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dgskr51ul9f6winuzkvd.png" alt="async"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To handle error in async await, we can use 'try and catch'&lt;/p&gt;

&lt;p&gt;Look at the code below for the same:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cOMZtHXv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/omf2k6zx93jfb6y4v08n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cOMZtHXv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/omf2k6zx93jfb6y4v08n.png" alt="async err"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;The web browsers define functions and APIs that allow us to register functions that should not be executed synchronously, and should instead be invoked asynchronously when some kind of event occurs. If we're running an operation that takes time however, like querying a database and using the results to populate templates, it is better to push this off the stack and complete the task asynchronously. Over time, you'll learn when it makes more sense to choose an asynchronous technique over a synchronous one.&lt;/p&gt;

&lt;p&gt;See you in next article. Goodbye 🖐.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>async</category>
      <category>programming</category>
      <category>fundamentals</category>
    </item>
    <item>
      <title>Data Structures &amp; Algorithms in JavaScript -- PS-1.</title>
      <dc:creator>Shaik Dawood</dc:creator>
      <pubDate>Wed, 04 Aug 2021 06:20:13 +0000</pubDate>
      <link>https://dev.to/dawoodxp97/data-structures-algorithms-in-javascript-ps-1-4p3b</link>
      <guid>https://dev.to/dawoodxp97/data-structures-algorithms-in-javascript-ps-1-4p3b</guid>
      <description>&lt;h2&gt;
  
  
  Given an array, find the first pair whose sum is equal to zero?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Input = [-5, -4, -3, -2, 0, 2, 4, 6, 8].
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Output = [-4, 4].
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
Check the given array is sorted or not. If not sort the array.&lt;/p&gt;

&lt;h5&gt;
  
  
  Approach 1:
&lt;/h5&gt;

&lt;p&gt;We need to traverse the each and every element of the array and compare it with other elements of the array.&lt;br&gt;
We have to apply two loops in it. The first loop (outer one) will start traversing from 0 index of the array and the second loop (inner one ) will start traversing from 1 index of the array. If the sum of  0th index of array and 1st index of array is equal to ZERO then return the pair.&lt;br&gt;
By using this approach we will get &lt;strong&gt;Quadratic Time Complexity O(n²).&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kijaY7g2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eja9lflw8k0wotvrn8r5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kijaY7g2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eja9lflw8k0wotvrn8r5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Approach 2:
&lt;/h5&gt;

&lt;p&gt;Let's assume to variables and assign them with 0 index and last index of array:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;let left = 0;&lt;/li&gt;
&lt;li&gt;let right = array.length - 1 ;
We need to run a single loop in which we will check if the sum of the left index value and right index value of the given array is equal to Zero, then return that Pair. If sum (left, right) &amp;gt; 0 then decrement the right variable (right--). If sum (left, right) &amp;lt; 0 then increment the left variable(left++).
By this approach we can get the Pair of Sum Zero in only one loop.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T4J-70t1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9zyjyhpstz1zylhw5dq.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By using this approach we will get &lt;strong&gt;Linear Time Complexity O(n).&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>algorithms</category>
      <category>tutorial</category>
      <category>arrays</category>
    </item>
  </channel>
</rss>
