<?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: MERN Practical Explanation</title>
    <description>The latest articles on DEV Community by MERN Practical Explanation (@mern_practical).</description>
    <link>https://dev.to/mern_practical</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%2F1244013%2F5d285803-64ed-48fd-bb3e-2090d4ebef5b.png</url>
      <title>DEV Community: MERN Practical Explanation</title>
      <link>https://dev.to/mern_practical</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mern_practical"/>
    <language>en</language>
    <item>
      <title>reset</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Fri, 09 Feb 2024 12:50:17 +0000</pubDate>
      <link>https://dev.to/mern_practical/reset-15mn</link>
      <guid>https://dev.to/mern_practical/reset-15mn</guid>
      <description>&lt;p&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;br&gt;
&lt;/p&gt;


&lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    Document&lt;br&gt;



&lt;br&gt;
    &lt;br&gt;
        &lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
            style="width:600px;background-color:rgb(255,255,255);margin:0 auto;border-spacing:0;border-collapse:collapse"&amp;gt;&lt;br&gt;
            &lt;tbody&gt;
&lt;br&gt;
                &lt;tr&gt;
&lt;br&gt;
                    &lt;td&gt;
&lt;br&gt;
                        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZlgUnCGY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/logo.png%3Falt%3Dmedia%26token%3Dad9b04dc-829f-47f5-8817-b38b604adf61" width="185" height="44"&gt;&lt;br&gt;
                    &lt;/td&gt;
&lt;br&gt;
                &lt;/tr&gt;
&lt;br&gt;
                &lt;tr&gt;
&lt;br&gt;
                    &lt;td&gt;
                        style="text-align: center; padding:0px 40px;height:260px;background-image:url('https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/banner-back.png?alt=media&amp;amp;token=aab58c6e-7713-4569-b2b3-9eeba20cd146');background-position:center top;background-size:cover;background-repeat:no-repeat"&amp;gt;&lt;br&gt;
                        &lt;h1&gt;
                            style="text-align:center;color:#fff;font-size:36px;font-family: 'Lato', sans-serif;font-style:italic;font-weight:700;padding:0;margin:0"&amp;gt;&lt;br&gt;
                            Hello ${name},&lt;/h1&gt;
&lt;br&gt;
                        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W4J7fOb---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/under-lines.png%3Falt%3Dmedia%26token%3D22d73f4b-2cbb-4174-bb65-1ed9db1c7377" alt="underline" width="168" height="13"&gt;&lt;br&gt;
                        &lt;p&gt;
                            style="text-align:center;color:#fff;font-family: 'Lato', sans-serif;font-weight:700;font-size:36px;padding-top:5px;margin:0"&amp;gt;&lt;br&gt;
                            Welcome to VMycards&lt;/p&gt;


&lt;p&gt;&lt;br&gt;
                            style="text-align:center;color:#fff;font-family: 'Lato', sans-serif;font-weight:400;font-size:16px;padding-top:10px;margin:0"&amp;gt;&lt;br&gt;&lt;br&gt;
                            congratulations on being eligible to save up on carbon footprint by replacing traditional&lt;br&gt;&lt;br&gt;
                            paper business cards with VMycards.&lt;br&gt;&lt;br&gt;
                        &lt;/p&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                    &lt;/td&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                &lt;/tr&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                &lt;tr&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                    &lt;td&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                        &lt;h5&gt;
&lt;br&gt;
                            style="color:#000;text-align:center;font-size:20px;font-style:normal;font-weight:600;margin-bottom:0"&amp;gt;&lt;br&gt;&lt;br&gt;
                            We are excited to have you on board.&lt;br&gt;&lt;br&gt;
                        &lt;/h5&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                        &lt;p&gt;&lt;br&gt;
                            style="text-align:center;color:#000;font-family: 'Lato', sans-serif;font-weight:400;font-size:16px;padding-top:10px;margin:0"&amp;gt;&lt;br&gt;&lt;br&gt;
                            Kindly verify your email address to proceed ahead. &lt;br&gt; Click on the verification link:&lt;br&gt;&lt;br&gt;
                        &lt;/p&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                    &lt;/td&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                &lt;/tr&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                &lt;tr&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
                    &lt;td&gt;
&lt;br&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                        style="display:inline-block;border-radius:5px;background:#032140;color:#fff;margin:20px 0 20px;text-transform:uppercase;padding:15px 35px"&amp;amp;gt;&amp;lt;br&amp;gt;
                        &amp;lt;a href="${activateLink}"&amp;gt;&amp;lt;br&amp;gt;
                            verify Email&amp;lt;br&amp;gt;
                        &amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    &amp;lt;/div&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td style="text-align:center"&amp;gt;
                    &amp;lt;h5
                        style="color:#000;text-align:center;font-size:24px;font-style:normal;font-weight:600;margin:25px 0 0"&amp;gt;
                        Why you should opt for &amp;lt;span style="color:#085EA9"&amp;gt;VMycards?&amp;lt;/span&amp;gt;&amp;lt;/h5&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;

            &amp;lt;tr&amp;gt;
                &amp;lt;td style="text-align:center"&amp;gt;
                    &amp;lt;img style="padding-left:250px;width:30px" src="https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/arrow.png?alt=media&amp;amp;token=7622a017-36d8-42d5-81f8-f4e79f069cc8" class="CToWUd" data-bit="iit"&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;

            &amp;lt;tr&amp;gt;
                &amp;lt;td style="text-align:center; padding-top: 0; padding-bottom: 0;line-height: 0;"&amp;gt;
                    &amp;lt;img src="https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/find-img.png?alt=media&amp;amp;token=8aa7acdf-89bd-44e3-89f5-8cae10f8cd24" class="CToWUd a6T" data-bit="iit" tabindex="0"&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;

            &amp;lt;tr&amp;gt;
                &amp;lt;td style="text-align:center;background-color:#EEEEEE;padding-bottom:20px"&amp;gt;
                    &amp;lt;div
                        style="display:inline-block;border-radius:5px;background:#032140;color:#fff;margin:20px 0 20px;text-transform:uppercase;padding:15px 35px"&amp;gt;
                        &amp;lt;a href="https://vmycards.com/" style="color:#fff;text-decoration:none" target="_blank"
                            data-saferedirecturl="#"&amp;gt;
                            CREATE YOUR CARD&amp;lt;/a&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td&amp;gt;
                    &amp;lt;h5
                        style="color:#0059A6;text-align:center;font-size:24px;font-style:normal;font-weight:700;margin-bottom:0"&amp;gt;
                        Professional
                    &amp;lt;/h5&amp;gt;
                    &amp;lt;p
                        style="text-align:center;color:#000;font-family: 'Lato', sans-serif;font-weight:400;font-size:20px;padding-top:10px;margin:0"&amp;gt;
                        Modern, sleek digital cards for a professional edge.
                    &amp;lt;/p&amp;gt;
                    &amp;lt;h5
                        style="color:#0059A6;text-align:center;font-size:24px;font-style:normal;font-weight:700;margin-bottom:0"&amp;gt;
                        Customizable
                    &amp;lt;/h5&amp;gt;
                    &amp;lt;p
                        style="text-align:center;color:#000;font-family: 'Lato', sans-serif;font-weight:400;font-size:20px;padding-top:10px;margin:0"&amp;gt;
                        Reflect your brand with logo and colors.
                    &amp;lt;/p&amp;gt;
                    &amp;lt;h5
                        style="color:#0059A6;text-align:center;font-size:24px;font-style:normal;font-weight:700;margin-bottom:0"&amp;gt;
                        Eco-friendly
                    &amp;lt;/h5&amp;gt;
                    &amp;lt;p
                        style="text-align:center;color:#000;font-family: 'Lato', sans-serif;font-weight:400;font-size:20px;padding-top:10px;margin-bottom:10px; margin-top: 0;"&amp;gt;
                        Ditch paper for sustainable networking.
                    &amp;lt;/p&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;


            &amp;lt;tr style="margin-top:20px;width:100%"&amp;gt;
                &amp;lt;td style="display:flex;margin-top:15px"&amp;gt;
                    &amp;lt;img style="width:100%" src="https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/men-child-left.png?alt=media&amp;amp;token=e35f8a86-1f10-4ff8-9b2e-ffb8a8c4819a" class="CToWUd a6T" data-bit="iit"
                        tabindex="0"&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;

            &amp;lt;tr&amp;gt;
                &amp;lt;td&amp;gt;
                    &amp;lt;h2
                        style="color:#000;text-align:center;font-size:20px;font-style:normal;font-weight:400;padding:20px 60px"&amp;gt;
                        If you have any questions or need assistance, we’re &amp;lt;br /&amp;gt; here to help 24x7
                    &amp;lt;/h2&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;

            &amp;lt;tr&amp;gt;
                &amp;lt;td style="text-align:center"&amp;gt;
                    &amp;lt;div style="display:inline-flex;margin-bottom:20px"&amp;gt;
                        &amp;lt;img src="https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/support-icon.png?alt=media&amp;amp;token=e4df40f7-3952-46fc-a2d0-1fac9cbe83c2" alt=""
                            style="text-align:center;width:25px;height:25px;padding: 5px; background: #EAF7FF; border-radius: 50%;"
                            class="CToWUd" data-bit="iit"&amp;gt;
                        &amp;lt;div style="padding-left:10px;text-align:left"&amp;gt;
                            &amp;lt;h5 style="margin:0;font-size:18px;color:#000;font-weight:400"&amp;gt;Customer Service
                                Department&amp;lt;/h5&amp;gt;
                            &amp;lt;h5 style="margin:0;font-size:18px;color:#009cff;font-weight:400"&amp;gt;&amp;lt;a
                                    href="mailto:Support@vmycards.com" target="_blank"&amp;gt;Support@vmycards.com&amp;lt;/a&amp;gt;&amp;lt;/h5&amp;gt;
                        &amp;lt;/div&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td style="text-align:center"&amp;gt;
                    &amp;lt;div style="display:inline-flex;margin-bottom:20px"&amp;gt;
                        &amp;lt;img src="https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/support-email.png?alt=media&amp;amp;token=b03b0012-84f0-4db4-9dba-eb73fcc6709e" alt=""
                            style="text-align:center;width:25px;height:25px;padding: 5px; background: #EAF7FF; border-radius: 50%;"
                            class="CToWUd" data-bit="iit"&amp;gt;
                        &amp;lt;div style="padding-left:10px;text-align:left"&amp;gt;
                            &amp;lt;h5 style="margin:0;font-size:18px;color:#000;font-weight:400"&amp;gt;Complaints &amp;amp;amp;
                                Suggestions&amp;lt;/h5&amp;gt;
                            &amp;lt;h5 style="margin:0;font-size:18px;color:#009cff;font-weight:400"&amp;gt;&amp;lt;a
                                    href="mailto:complaints@vmycards.com" target="_blank"&amp;gt;Complaints@vmycards.com&amp;lt;/a&amp;gt;
                            &amp;lt;/h5&amp;gt;
                        &amp;lt;/div&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td style="text-align:center"&amp;gt;
                    &amp;lt;div style="display:inline-flex;margin-bottom:20px"&amp;gt;
                        &amp;lt;img src="https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/support-call.png?alt=media&amp;amp;token=689096b1-6b44-4d7d-ad1b-25e40566f86c" alt=""
                            style="text-align:center;width:25px;height:25px;padding: 5px; background: #EAF7FF; border-radius: 50%;"
                            class="CToWUd" data-bit="iit"&amp;gt;
                        &amp;lt;div style="padding-left:10px;text-align:left"&amp;gt;
                            &amp;lt;h5 style="margin:0;font-size:18px;color:#000;font-weight:400"&amp;gt;Call: +1 (121) 253-542
                            &amp;lt;/h5&amp;gt;
                            &amp;lt;h5 style="margin:0;font-size:18px;color:#009cff;font-weight:400"&amp;gt;24*7&amp;lt;/h5&amp;gt;
                        &amp;lt;/div&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;

            &amp;lt;tr&amp;gt;
                &amp;lt;td style="background-color:#032140;padding-top:40px; padding-bottom:40px;text-align:center"&amp;gt;
                    &amp;lt;img src="https://firebasestorage.googleapis.com/v0/b/vmycard-e1da0.appspot.com/o/white-logo.png?alt=media&amp;amp;token=5a82f551-8efd-4c60-b078-0c350e610218" class="CToWUd" data-bit="iit"&amp;gt;
                    &amp;lt;h2
                        style="color:#fff;text-align:center;font-size:14px;font-style:normal;font-weight:400;margin:10px 0 5px"&amp;gt;
                        Thank you for choosing VMycards to transform the way you connect. We &amp;lt;br /&amp;gt; look forward to
                        being a
                        part of your journey towards more efficient and &amp;lt;br /&amp;gt; effective networking.
                    &amp;lt;/h2&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td style="background-color:#fff;text-align:center; padding: 15px 0;"&amp;gt;
                    &amp;lt;a href="#" style="color:#032140;text-decoration:none" target="_blank" data-saferedirecturl=""&amp;gt;
                        www.vmycards.com
                    &amp;lt;/a&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
        &amp;lt;/tbody&amp;gt;
    &amp;lt;/table&amp;gt;
    &amp;lt;div class="yj6qo"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div class="adL"&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;






&lt;/td&gt;
&lt;br&gt;
&lt;/tr&gt;
&lt;br&gt;
&lt;/tbody&gt;
&lt;br&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
    </item>
    <item>
      <title>Testing Libraries</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Wed, 07 Feb 2024 12:01:50 +0000</pubDate>
      <link>https://dev.to/mern_practical/testing-libraries-4o5o</link>
      <guid>https://dev.to/mern_practical/testing-libraries-4o5o</guid>
      <description>&lt;p&gt;Unit testing is a crucial practice in software development, including JavaScript. It involves testing individual units or components of your code in isolation to ensure they work as expected. Here's a basic overview of unit testing in JavaScript:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing Libraries:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are several popular testing libraries and frameworks for JavaScript. Two of the most widely used ones are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Jest:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Developed by Facebook, Jest is a comprehensive testing framework for JavaScript. It's easy to set up and comes with built-in assertion libraries, mocking capabilities, and parallel test execution.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example Jest test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="c1"&gt;// myFunction.js&lt;/span&gt;
   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="c1"&gt;// myFunction.test.js&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./myFunction&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

   &lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;adds 1 + 2 to equal 3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Mocha and Chai:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Mocha is a flexible testing framework, and Chai is an assertion library often used with Mocha. They provide a powerful combination for testing JavaScript applications.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example Mocha and Chai test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="c1"&gt;// myFunction.js&lt;/span&gt;
   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="c1"&gt;// myFunction.test.js&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;multiply&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./myFunction&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;chai&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

   &lt;span class="nf"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Multiply function&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;should multiply 2 by 3 to equal 6&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="p"&gt;});&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Basic Steps for Unit Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install Testing Framework:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Jest or Mocha and Chai using a package manager like npm:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; // For Jest
 npm install --save-dev jest

 // For Mocha and Chai
 npm install --save-dev mocha chai
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Write Tests:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create test files alongside your source files, following a naming convention (e.g., &lt;code&gt;myFunction.js&lt;/code&gt; and &lt;code&gt;myFunction.test.js&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Write test cases using the testing framework's syntax.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Run Tests:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Execute the tests using the testing framework's command-line interface or by integrating testing into your build process.&lt;/li&gt;
&lt;li&gt;For Jest, you can run tests using the &lt;code&gt;jest&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;For Mocha, you can run tests with the &lt;code&gt;mocha&lt;/code&gt; command.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example Jest command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Example Mocha command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   npx mocha myFunction.test.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Assertions:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Use assertions to verify that the actual output of your code matches the expected output.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Both Jest and Mocha allow you to mock dependencies to isolate your tests further. Mocking is useful when you want to control the behavior of external dependencies during testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Continuous Integration (CI):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Consider integrating your unit tests into a continuous integration (CI) pipeline to automatically run tests whenever code changes are pushed.&lt;/p&gt;

&lt;p&gt;Remember that writing good unit tests involves covering various scenarios, including edge cases and error conditions, to ensure the reliability of your code.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Client-side rendering (CSR) and server-side rendering (SSR)</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Wed, 07 Feb 2024 12:00:43 +0000</pubDate>
      <link>https://dev.to/mern_practical/client-side-rendering-csr-and-server-side-rendering-ssr-4lgf</link>
      <guid>https://dev.to/mern_practical/client-side-rendering-csr-and-server-side-rendering-ssr-4lgf</guid>
      <description>&lt;p&gt;Client-side rendering (CSR) and server-side rendering (SSR) are two approaches used in web development to handle the generation and presentation of content on a website. They have different characteristics and implications for performance, user experience, and development workflows.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Client-Side Rendering (CSR):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; In CSR, the browser takes on the responsibility of rendering the web page. The server sends a minimal HTML document along with JavaScript, and the browser executes the JavaScript to fetch data and generate the DOM dynamically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Faster initial page load: Only minimal HTML and JavaScript need to be transferred initially.&lt;/li&gt;
&lt;li&gt;Good for dynamic, single-page applications (SPAs) where interactions happen within the page without full page reloads.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Slower time to content: The browser needs to download and execute JavaScript before rendering the content, which may result in a delay.&lt;/li&gt;
&lt;li&gt;Poor SEO performance: Search engine crawlers may have difficulty indexing content that relies heavily on JavaScript.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Server-Side Rendering (SSR):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; With SSR, the server sends fully rendered HTML to the browser. The server executes the JavaScript, fetches data, and generates the HTML on the server side before sending it to the client.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Faster time to content: The browser receives pre-rendered HTML, reducing the time it takes to display content.&lt;/li&gt;
&lt;li&gt;Better SEO performance: Search engines can easily index the content since it's present in the initial HTML response.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Slower initial page load: The entire HTML document, along with the data, needs to be sent from the server to the client, potentially resulting in a longer initial load time.&lt;/li&gt;
&lt;li&gt;May be less suitable for highly dynamic, client-side interactions without additional optimizations.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Developers often use a hybrid approach, combining both CSR and SSR, to leverage the benefits of each method. This is known as "universal" or "isomorphic" rendering, where some parts of the page are rendered on the server, and others are handled on the client side. This approach aims to strike a balance between initial load performance and dynamic client-side interactions.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>React.js Key Concepts</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Wed, 07 Feb 2024 11:59:20 +0000</pubDate>
      <link>https://dev.to/mern_practical/reactjs-key-concepts-3kf9</link>
      <guid>https://dev.to/mern_practical/reactjs-key-concepts-3kf9</guid>
      <description>&lt;p&gt;Certainly! React.js is a popular JavaScript library for building user interfaces, developed and maintained by Facebook. Here's a brief overview:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is React.js?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React.js, often referred to as React, is an open-source JavaScript library used for building user interfaces or UI components. It allows developers to create reusable UI components and build complex user interfaces efficiently.&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Component-Based Architecture:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React follows a component-based architecture, where UIs are divided into independent and reusable components. Components can have their own state and lifecycle methods.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Virtual DOM:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React uses a virtual DOM (Document Object Model) to improve performance. Instead of directly manipulating the actual DOM, React creates a virtual representation of it in memory, making updates more efficient.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JSX (JavaScript XML):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSX is a syntax extension for JavaScript recommended by React. It allows you to write HTML-like code within JavaScript, making it easier to describe the UI structure. JSX gets compiled into JavaScript.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unidirectional Data Flow:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React follows a unidirectional data flow, meaning data changes in one direction—from parent components to child components. This makes it easier to understand how data is being passed and modified in an application.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;State and Props:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Components can have state, which represents their internal data. Props (short for properties) are used to pass data from a parent component to a child component.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lifecycle Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React components have lifecycle methods (e.g., &lt;code&gt;componentDidMount&lt;/code&gt;, &lt;code&gt;componentDidUpdate&lt;/code&gt;, &lt;code&gt;componentWillUnmount&lt;/code&gt;) that allow developers to perform actions at different stages of a component's existence.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;React Router:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React Router is a popular library for handling navigation in React applications. It allows for the creation of single-page applications with multiple views.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Why Use React.js?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Declarative Syntax:&lt;/strong&gt; React uses a declarative syntax, making it easier to understand and debug code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficient Updates:&lt;/strong&gt; Through the virtual DOM, React optimizes updates and enhances application performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Component Reusability:&lt;/strong&gt; Components can be reused, promoting a modular and maintainable codebase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community and Ecosystem:&lt;/strong&gt; React has a large and active community, and it's supported by a vast ecosystem of libraries and tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Getting Started:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To start using React, you typically set up a development environment using tools like Create React App or configure a build system like Webpack. React can be integrated with other libraries and frameworks as needed.&lt;/p&gt;

&lt;p&gt;Here's a simple example of a React component in JSX:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello, React!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is just a brief introduction; React has many more features and capabilities. If you have specific questions or if there's a particular aspect of React you'd like to know more about, feel free to ask!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>useEffect Practicle</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Wed, 07 Feb 2024 05:06:00 +0000</pubDate>
      <link>https://dev.to/mern_practical/useeffect-practicle-1cal</link>
      <guid>https://dev.to/mern_practical/useeffect-practicle-1cal</guid>
      <description>&lt;p&gt;Certainly! I've added more detailed comments to help explain each section of the &lt;code&gt;useEffect&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Check if both selectedDateTo and selectedDateFrom are not empty&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedDateTo&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;selectedDateFrom&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Check if selectedDateTo is less than selectedDateFrom&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedDateTo&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;selectedDateFrom&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Display a warning toast if the condition is true&lt;/span&gt;
      &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;warning&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;To Date should be equal to or greater than From Date&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;POSITION&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TOP_RIGHT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="c1"&gt;// Return early to prevent further execution&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Check if All Status is selected and no date range is specified&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;activeBusinessStatus&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;All Status&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;selectedDateFrom&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;selectedDateTo&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// If true, set the business list data to the original tempData&lt;/span&gt;
    &lt;span class="nf"&gt;setBusinesslistData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tempData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Initialize filteredData with the original tempData&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;filteredData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tempData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Check if a specific business status is selected&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;activeBusinessStatus&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;activeBusinessStatus&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;All Status&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Filter the data based on the selected status&lt;/span&gt;
      &lt;span class="nx"&gt;filteredData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;filteredData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;activeBusinessStatus&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Check if a date range is specified&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedDateFrom&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;selectedDateTo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Output filteredData to the console for debugging&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filteredData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;filteredData fetch admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="c1"&gt;// Filter the data based on the specified date range&lt;/span&gt;
      &lt;span class="nx"&gt;filteredData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;filteredData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;selectedDateFrom&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;selectedDateTo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Set the filtered data to the component state&lt;/span&gt;
    &lt;span class="nf"&gt;setBusinesslistData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filteredData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;activeBusinessStatus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;selectedDateFrom&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;selectedDateTo&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These comments provide a detailed explanation of each block and condition within the &lt;code&gt;useEffect&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;Certainly! Let's break down the key concepts in simpler terms:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;useEffect&lt;/code&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In simple terms, &lt;code&gt;useEffect&lt;/code&gt; is a hook in React that allows you to perform side effects in your functional components.&lt;/li&gt;
&lt;li&gt;Side effects are operations or tasks that happen after the component renders, like data fetching, updating the DOM, or interacting with external services.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;filter&lt;/code&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;filter&lt;/code&gt; method is a way to sift through a collection of items (like an array) and pick out only the items that meet a certain condition.&lt;/li&gt;
&lt;li&gt;In your code, &lt;code&gt;filter&lt;/code&gt; is used to select specific items from the &lt;code&gt;tempData&lt;/code&gt; array based on conditions related to business status and date.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;Date&lt;/code&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Date&lt;/code&gt; object in JavaScript is used to work with dates and times.&lt;/li&gt;
&lt;li&gt;In your code, the &lt;code&gt;Date&lt;/code&gt; object is used to convert the &lt;code&gt;created_at&lt;/code&gt; property of each business item into a date object. This allows you to compare these dates and filter items based on a date range.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;[activeBusinessStatus, selectedDateFrom, selectedDateTo]&lt;/code&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is the dependency array for the &lt;code&gt;useEffect&lt;/code&gt;. It tells React to re-run the &lt;code&gt;useEffect&lt;/code&gt; whenever any of these values (&lt;code&gt;activeBusinessStatus&lt;/code&gt;, &lt;code&gt;selectedDateFrom&lt;/code&gt;, &lt;code&gt;selectedDateTo&lt;/code&gt;) change.&lt;/li&gt;
&lt;li&gt;In your code, it ensures that the filtering logic is applied whenever there's a change in the business status or the selected date range. It helps keep your component in sync with the latest data.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In simpler terms, the &lt;code&gt;useEffect&lt;/code&gt; with &lt;code&gt;filter&lt;/code&gt; and &lt;code&gt;Date&lt;/code&gt; is like a smart assistant that keeps an eye on changes in business status and selected dates. Whenever there's a change, it sifts through the business data and updates what you see on the screen accordingly. The dependency array is like a notification system that says, "Hey, pay attention to these specific things, and when they change, do your job!"&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Axios Filter Map live exampe</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Wed, 07 Feb 2024 04:45:46 +0000</pubDate>
      <link>https://dev.to/mern_practical/axios-filter-map-live-exampe-3ak6</link>
      <guid>https://dev.to/mern_practical/axios-filter-map-live-exampe-3ak6</guid>
      <description>&lt;p&gt;Certainly! Let's break down the &lt;code&gt;FetchSlots&lt;/code&gt; function and explain its structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;FetchSlots&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Step 1: Prepare request object with business_id set to 0&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;business_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;

        &lt;span class="c1"&gt;// Step 2: Make a POST request using axios&lt;/span&gt;
        &lt;span class="nx"&gt;axios&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;api/v1/appointment/FetchSlots`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="na"&gt;_token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;})&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;// Step 3: Extract unique business titles from response data&lt;/span&gt;
                &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tempArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;records&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;businessTitle&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;businessTitle&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;businessTitle&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tempUniqueArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tempArr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nx"&gt;tempUniqueArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;tempUniqueArr&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

                &lt;span class="c1"&gt;// Step 4: Set unique business titles to state variable 'setBusinessData'&lt;/span&gt;
                &lt;span class="nf"&gt;setBusinessData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tempUniqueArr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="c1"&gt;// Step 5: Extract and format relevant data from response&lt;/span&gt;
                &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newDataArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
                &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;records&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rs&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;slots&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rss&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rss&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;startDate&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;rss&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;endDate&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                            &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                                &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;business_id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;rss&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;formCount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="na"&gt;business_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;business_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="na"&gt;businessTitle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;businessTitle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="na"&gt;formCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;rss&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;formCount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="na"&gt;startDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;rss&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;startDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="na"&gt;endDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;rss&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;endDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;rss&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;NA&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="p"&gt;};&lt;/span&gt;
                            &lt;span class="nx"&gt;newDataArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                        &lt;span class="p"&gt;}&lt;/span&gt;
                    &lt;span class="p"&gt;});&lt;/span&gt;
                &lt;span class="p"&gt;});&lt;/span&gt;

                &lt;span class="c1"&gt;// Step 6: Set formatted data to state variables 'setTempData' and 'setData'&lt;/span&gt;
                &lt;span class="nf"&gt;setTempData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newDataArray&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nf"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newDataArray&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nf"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;})&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;// Step 7: Handle errors&lt;/span&gt;
                &lt;span class="nf"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Step 8: Handle any synchronous errors&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;erroror&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Preparing Request Object&lt;/strong&gt;: The function starts by creating an object &lt;code&gt;obj&lt;/code&gt; with &lt;code&gt;business_id&lt;/code&gt; set to 0.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Making POST Request&lt;/strong&gt;: Axios is used to make a POST request to a specific API endpoint (&lt;code&gt;${baseUrl}api/v1/appointment/FetchSlots&lt;/code&gt;). The request includes the &lt;code&gt;obj&lt;/code&gt; data and a header with the authorization token (&lt;code&gt;_token&lt;/code&gt;) from &lt;code&gt;userData&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Handling Response&lt;/strong&gt;: In the &lt;code&gt;.then&lt;/code&gt; block, the function processes the response data.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;a. &lt;strong&gt;Extracting Unique Business Titles&lt;/strong&gt;: It filters and maps business titles, removing empty or undefined values, and then uses a &lt;code&gt;Set&lt;/code&gt; to get unique values.&lt;/p&gt;

&lt;p&gt;b. &lt;strong&gt;Setting Business Data to State&lt;/strong&gt;: The unique business titles are set to the state variable &lt;code&gt;setBusinessData&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;c. &lt;strong&gt;Formatting Data&lt;/strong&gt;: The function extracts relevant data from the response, including &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;business_id&lt;/code&gt;, &lt;code&gt;businessTitle&lt;/code&gt;, &lt;code&gt;formCount&lt;/code&gt;, &lt;code&gt;startDate&lt;/code&gt;, &lt;code&gt;endDate&lt;/code&gt;, and &lt;code&gt;status&lt;/code&gt;. This data is formatted into a new array &lt;code&gt;newDataArray&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;d. &lt;strong&gt;Setting State Variables&lt;/strong&gt;: The formatted data is set to state variables &lt;code&gt;setTempData&lt;/code&gt; and &lt;code&gt;setData&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Handling Errors&lt;/strong&gt;: In the &lt;code&gt;.catch&lt;/code&gt; block, any errors that occur during the HTTP request are handled, and the loading state (&lt;code&gt;setIsLoading&lt;/code&gt;) is updated accordingly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Handling Synchronous Errors&lt;/strong&gt;: Any synchronous errors (outside the axios block) are caught in the &lt;code&gt;try-catch&lt;/code&gt; block, and an error message is logged.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: Ensure that the variables like &lt;code&gt;baseUrl&lt;/code&gt;, &lt;code&gt;axios&lt;/code&gt;, &lt;code&gt;setBusinessData&lt;/code&gt;, &lt;code&gt;setTempData&lt;/code&gt;, &lt;code&gt;setData&lt;/code&gt;, and &lt;code&gt;setIsLoading&lt;/code&gt; are defined and accessible in the scope where this function is used.&lt;/p&gt;

&lt;p&gt;Certainly! Let's break down and explain the &lt;code&gt;fetchApppointent&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fetchApppointent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Step 1: Log a message indicating the function is being executed&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;In fetchApppointent api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Step 2: Prepare the request object with business_id and filters&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;business_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;businessObjData&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;

        &lt;span class="c1"&gt;// Step 3: Format start and end dates if available&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formattedStartDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;selectedDateFrom&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedDateFrom&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;yyyy-MM-dd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formattedEndDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;selectedDateTo&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedDateTo&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;yyyy-MM-dd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="c1"&gt;// Step 4: Prepare filters object based on selected dates and active business name&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;filters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;startDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;formattedStartDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;endDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;formattedEndDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;business&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;activeBusinessName&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;All Business&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;activeBusinessName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;

        &lt;span class="c1"&gt;// Step 5: Make a POST request using axios to fetch appointments with pagination&lt;/span&gt;
        &lt;span class="nx"&gt;axios&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;api/v1/appointment/FetchAppointments_withpagination?page=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;limit=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;rowsPerPage&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;filters&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="na"&gt;_token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;},&lt;/span&gt;
                &lt;span class="na"&gt;withCredentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;})&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;// Step 6: Extract unique business titles from response data&lt;/span&gt;
                &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tempArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;records&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;businessTitle&lt;/span&gt;
                &lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tempUniqueArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tempArr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nx"&gt;tempUniqueArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;tempUniqueArr&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

                &lt;span class="c1"&gt;// Step 7: Set unique business titles to state variable 'setBusinessData'&lt;/span&gt;
                &lt;span class="nf"&gt;setBusinessData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tempUniqueArr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="c1"&gt;// Step 8: Sort and set the response records based on created_at date&lt;/span&gt;
                &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;records&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="c1"&gt;// Step 9: Set the sorted data to state variables 'setTempData' and 'setData'&lt;/span&gt;
                &lt;span class="nf"&gt;setTempData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nf"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="c1"&gt;// Step 10: Set total rows for pagination&lt;/span&gt;
                &lt;span class="nf"&gt;setPaginationTotalRows&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;pagination&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;totalCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="c1"&gt;// Step 11: Log the total count of appointments for debugging&lt;/span&gt;
                &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ttl ap&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;pagination&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;totalCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="c1"&gt;// Step 12: Set loading state to false&lt;/span&gt;
                &lt;span class="nf"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;})&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;// Step 13: Handle errors and set loading state to false&lt;/span&gt;
                &lt;span class="nf"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Step 14: Handle any synchronous errors and log an error message&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;erroror&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logging Message&lt;/strong&gt;: The function starts by logging a message to the console to indicate that it is being executed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Preparing Request Object&lt;/strong&gt;: The function creates an object &lt;code&gt;obj&lt;/code&gt; with &lt;code&gt;business_id&lt;/code&gt; based on the value of &lt;code&gt;businessObjData?.id&lt;/code&gt; or a default value of "2".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Formatting Dates&lt;/strong&gt;: The selected start and end dates are formatted using the &lt;code&gt;format&lt;/code&gt; function (assuming it's from a date formatting library, possibly &lt;code&gt;date-fns&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Preparing Filters Object&lt;/strong&gt;: The function creates a &lt;code&gt;filters&lt;/code&gt; object based on the formatted start and end dates and the active business name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Making POST Request&lt;/strong&gt;: Axios is used to make a POST request to a specific API endpoint (&lt;code&gt;${baseUrl}api/v1/appointment/FetchAppointments_withpagination&lt;/code&gt;). The request includes the merged &lt;code&gt;obj&lt;/code&gt; and &lt;code&gt;filters&lt;/code&gt; objects, and it includes headers and credentials information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Handling Response&lt;/strong&gt;: In the &lt;code&gt;.then&lt;/code&gt; block, the function processes the response data.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;a. &lt;strong&gt;Extracting Unique Business Titles&lt;/strong&gt;: Unique business titles are extracted from the response data.&lt;/p&gt;

&lt;p&gt;b. &lt;strong&gt;Setting Business Data to State&lt;/strong&gt;: Unique business titles are set to the state variable &lt;code&gt;setBusinessData&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;c. &lt;strong&gt;Sorting Data&lt;/strong&gt;: The response records are sorted based on the &lt;code&gt;created_at&lt;/code&gt; date in descending order.&lt;/p&gt;

&lt;p&gt;d. &lt;strong&gt;Setting State Variables&lt;/strong&gt;: The sorted data is set to state variables &lt;code&gt;setTempData&lt;/code&gt; and &lt;code&gt;setData&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;e. &lt;strong&gt;Setting Total Rows for Pagination&lt;/strong&gt;: The total count of appointments for pagination is extracted and set to the state variable &lt;code&gt;setPaginationTotalRows&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;f. &lt;strong&gt;Logging Total Count&lt;/strong&gt;: The total count of appointments is logged for debugging.&lt;/p&gt;

&lt;p&gt;g. &lt;strong&gt;Setting Loading State&lt;/strong&gt;: The loading state is set to false.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Handling Errors&lt;/strong&gt;: In the &lt;code&gt;.catch&lt;/code&gt; block, any errors that occur during the HTTP request are handled, and the loading state (&lt;code&gt;setIsLoading&lt;/code&gt;) is updated accordingly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Handling Synchronous Errors&lt;/strong&gt;: Any synchronous errors (outside the axios block) are caught in the &lt;code&gt;try-catch&lt;/code&gt; block, and an error message is logged.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: Ensure that the variables like &lt;code&gt;baseUrl&lt;/code&gt;, &lt;code&gt;axios&lt;/code&gt;, &lt;code&gt;setBusinessData&lt;/code&gt;, &lt;code&gt;setTempData&lt;/code&gt;, &lt;code&gt;setData&lt;/code&gt;, &lt;code&gt;setPaginationTotalRows&lt;/code&gt;, &lt;code&gt;setIsLoading&lt;/code&gt;, &lt;code&gt;businessObjData&lt;/code&gt;, &lt;code&gt;selectedDateFrom&lt;/code&gt;, &lt;code&gt;selectedDateTo&lt;/code&gt;, &lt;code&gt;activeBusinessName&lt;/code&gt;, &lt;code&gt;userData&lt;/code&gt;, &lt;code&gt;rowsPerPage&lt;/code&gt;, and &lt;code&gt;format&lt;/code&gt; are defined and accessible in the scope where this function is used.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Filter use in React</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Wed, 07 Feb 2024 04:41:03 +0000</pubDate>
      <link>https://dev.to/mern_practical/filter-use-in-react-526f</link>
      <guid>https://dev.to/mern_practical/filter-use-in-react-526f</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;filteredData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;selectedCategory&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// If no category is selected, include all items&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedCategory&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Salon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedCategory&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Contructor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedCategory&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Doctor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedCategory&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Teacher&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleToggle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;expandedItems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setExpandedItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;expandedItems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;expandedItem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;expandedItem&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setExpandedItems&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleEditUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;usersData&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;editUserData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;usersData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;setUserId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;setUserCreateData&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;editUserData&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]?.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;editUserData&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]?.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="c1"&gt;// password: "",&lt;/span&gt;
        &lt;span class="na"&gt;roleId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;editUserData&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]?.&lt;/span&gt;&lt;span class="nx"&gt;role_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;users not available&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;searchByRoleId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setUsersData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;usersDataApi&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;searchOption&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;-1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;searchInput&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newUsersData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;usersDataApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;role_id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;searchOption&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;setUsersData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newUsersData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="c1"&gt;// item?.role_name.toLowerCase().includes(searchInput?.toLowerCase())&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;searchInput&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;searchOption&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;-1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newUsersData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;usersDataApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;searchInput&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;setUsersData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newUsersData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;searchInput&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;searchOption&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newUsersData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;usersDataApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;role_id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;searchOption&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newUsersData2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newUsersData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;searchInput&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;setUsersData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newUsersData2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setUsersData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;usersDataApi&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

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

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Data Types</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Wed, 07 Feb 2024 04:34:01 +0000</pubDate>
      <link>https://dev.to/mern_practical/data-types-99g</link>
      <guid>https://dev.to/mern_practical/data-types-99g</guid>
      <description>&lt;p&gt;JavaScript Data Types&lt;br&gt;
JavaScript provides different data types to hold different types of Values. &lt;br&gt;
There are two types of data types in Java Script:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Primitive data type: it means ,it represent single value &lt;/li&gt;
&lt;li&gt;Non- primitive data type: an object which represents a collection of values.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Var a = 40://holding number&lt;br&gt;
var b="Rahul"; // holding String&lt;/p&gt;

&lt;p&gt;JavaScript Primitive data types&lt;/p&gt;

&lt;p&gt;String: represents Sequence of characters e.g. "hello" &lt;/p&gt;

&lt;p&gt;Number: represents numeric Values e.g. 100&lt;/p&gt;

&lt;p&gt;Boolean Represents boolean Value either false or true&lt;br&gt;
Underfined: represents undefined Value&lt;br&gt;
Null: represents null i.e. no value at all&lt;/p&gt;

&lt;p&gt;1:)Primitive: this value are immutable. this are pass by value.means To store single values.e.g.String,Number,Boolean,Undefined,Null.&lt;/p&gt;

&lt;p&gt;Primitive types: Primitive data types can store only a single value. &lt;/p&gt;

&lt;p&gt;typeof of primitive types :&lt;br&gt;
typeof "John Doe" // Returns "string"&lt;br&gt;
typeof 3.14 // Returns "number"&lt;br&gt;
typeof true // Returns "boolean"&lt;br&gt;
typeof 234567890123456789012345678901234567890n // Returns bigint&lt;br&gt;
typeof undefined // Returns "undefined"&lt;br&gt;
typeof null // Returns "object" (kind of a bug in JavaScript)&lt;br&gt;
typeof Symbol('symbol') // Returns Symbol&lt;/p&gt;

&lt;p&gt;In JavaScript, when we pass a primitive data type (such as Number, String, Boolean, Undefined, Null, or Symbol) to a function, it is passed by value. This means that a copy of the value is created and passed to the function, so that the original value remains unchanged.&lt;br&gt;
For example:&lt;br&gt;
let x = 10;&lt;/p&gt;

&lt;p&gt;function changeValue(num) {&lt;br&gt;
    num = 20;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;changeValue(x);&lt;br&gt;
console.log(x);  // Output: 10&lt;/p&gt;

&lt;p&gt;In this example, the changeValue function takes a num parameter, which is a primitive data type (Number). When we call changeValue(x), a copy of the value of x (10) is passed to the function. Within the function, we assign a new value of 20 to num. However, this change does not affect the original value of x, which remains 10.&lt;br&gt;
This is because primitive data types are passed by value in JavaScript, meaning that a copy of the value is created and passed to the function, so that the original value remains unchanged&lt;/p&gt;

&lt;p&gt;2:) Non Primitive&lt;br&gt;
(To store multiple values)-&amp;gt;( value are mutable) (pass by reference):Object,Array.&lt;/p&gt;

&lt;p&gt;Non-primitive types&lt;br&gt;
To store multiple and complex values, non-primitive data types are used.&lt;/p&gt;

&lt;p&gt;In JavaScript, when we pass an object (including arrays and functions) to a function, it is passed by reference. This means that a reference to the object, is passed to the function.&lt;br&gt;
For example:&lt;br&gt;
let person = { name: "John Doe", age: 26 };&lt;/p&gt;

&lt;p&gt;function changeName(obj) {&lt;br&gt;
    obj.name = "Jane Doe";&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;changeName(person);&lt;br&gt;
console.log(person.name);  // Output: "Jane Doe"&lt;br&gt;
In this example, the changeName function takes an obj parameter, which is an object. When we call changeName(person), a reference to the person object is passed to the function. Within the function, we change the name property of the object to "Jane Doe".&lt;br&gt;
Since objects are passed by reference in JavaScript, this change is reflected in the original person object, so that its name property is now "Jane Doe".&lt;br&gt;
This is because objects in JavaScript are passed by reference, meaning that a reference to the object, rather than a copy of its value, is passed to the function. Any changes made to the object within the function are therefore reflected in the original object, as it is the same object.&lt;/p&gt;

&lt;p&gt;11) The keyword is a reference variable that refers to the current object.For example:&lt;/p&gt;

&lt;p&gt;13)The parseInt() function is used to convert numbers between different bases. &lt;br&gt;
    parseInt() takes the string to be converted as its first parameter. &lt;br&gt;
    The second parameter is the base of the given string.&lt;/p&gt;

&lt;p&gt;Mutable is a type of variable that can be changed. In JavaScript, only objects and arrays are mutable, not primitive values.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Why we use await ?&lt;br&gt;&lt;br&gt;
Ans-Await is used for calling an async function and waits for it to resolve or reject . &lt;br&gt;
await blocks the execution of the code within the async function in which it is located. Async/Await makes it easier to write promises. &lt;br&gt;
The keyword 'async' before a function makes the function return a promise, always. And the keyword await is used inside async functions, which makes the program wait until the Promise resolves.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is mutable?&lt;br&gt;&lt;br&gt;
Ans-A mutable object is an object whose state can be modified after it is created. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Immutables are the objects whose state cannot be changed once it is created. Strings and Numbers are Immutable.  &lt;/p&gt;

&lt;p&gt;let x= {}, y = {name:"Ronny"},z = {name:"John"};&lt;/p&gt;

&lt;p&gt;x[y] = {name:"Vivek"};&lt;br&gt;
x[z] = {name:"Akki"};&lt;/p&gt;

&lt;p&gt;console.log(x[y]);&lt;br&gt;
In JavaScript, when an object is used as a key in another object, it is automatically converted to a string using the toString() method. In this case, both y and z are objects, so they will be converted to strings and used as keys in the x object.&lt;br&gt;
Here's what's happening in the code:&lt;br&gt;
let x = {}, y = {name:"Ronny"}, z = {name:"John"};&lt;br&gt;
x[y] = {name:"Vivek"}; // Set x["[object Object]"] = {name:"Vivek"}&lt;br&gt;
x[z] = {name:"Akki"};  // Set x["[object Object]"] = {name:"Akki"}&lt;br&gt;
console.log(x[y]);     // Logs {name:"Akki"}&lt;br&gt;
In this code, the x object is being assigned two properties: x[y] and x[z]. Since y and z are both objects, they are both converted to the string "[object Object]" and used as keys in the x object.&lt;br&gt;
The first assignment sets the x["[object Object]"] property to {name:"Vivek"}. The second assignment overwrites the x["[object Object]"] property with {name:"Akki"}.&lt;br&gt;
When console.log(x[y]) is called, it retrieves the value of x["[object Object]"], which is {name:"Akki"} because it was the last value assigned to that key.&lt;/p&gt;

&lt;p&gt;Pundarikaksha Mishra6:04 PM&lt;br&gt;
let a = 0;&lt;br&gt;
let b = false;&lt;br&gt;
console.log((a == b));&lt;br&gt;
console.log((a === b));&lt;/p&gt;

&lt;p&gt;what is concurrent  in node js&lt;br&gt;
Concurrency is an essential feature of Node. js that enables it to handle large numbers of I/O operations simultaneously, without blocking the execution thread. This concurrency model allows Node. js to handle many requests concurrently, resulting in improved application performance&lt;/p&gt;

&lt;p&gt;JavaScript Operators&lt;br&gt;
 JavaScript Operators are symbols that are used to perform Operations on operands.&lt;/p&gt;

&lt;p&gt;JavaScript includes following categories of operators.&lt;/p&gt;

&lt;p&gt;Arithmetic Operators: use to perform arithmetic operation on the operands.&lt;br&gt;
E.  g:&lt;/p&gt;

&lt;p&gt;Operator    Description Example&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Addition    10+20 = 30&lt;/li&gt;
&lt;li&gt;  Subtraction 20-10 = 10&lt;/li&gt;
&lt;li&gt;  Multiplication  10*20 = 200
/   Division    20/10 = 2
%   Modulus (Remainder) 20%10 = 0
++  Increment   var a=10; a++; Now a = 11
--  Decrement   var a=10; a--; Now a = 9&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Comparison Operators:&lt;/p&gt;

&lt;p&gt;The JavaScript comparison operator compares the two operands. The comparison operators are as follows:&lt;br&gt;
Operator    Description Example&lt;br&gt;
==  Is equal to 10==20 = false&lt;br&gt;
=== Identical (equal and of same type)  10==20 = false&lt;br&gt;
!=  Not equal to    10!=20 = true&lt;br&gt;
!== Not Identical   20!==20 = false&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Greater than    20&amp;gt;10 = true&lt;br&gt;
=  Greater than or equal to    20&amp;gt;=10 = true&lt;br&gt;
&amp;lt;   Less than   20&amp;lt;10 = false&lt;br&gt;
&amp;lt;=  Less than or equal to   20&amp;lt;=10 = false&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Logical Operators:&lt;/p&gt;

&lt;p&gt;The following operators are known as JavaScript logical operators.&lt;br&gt;
Operator    Description Example&lt;br&gt;
&amp;amp;&amp;amp;  Logical AND (10==20 &amp;amp;&amp;amp; 20==33) = false&lt;br&gt;
||  Logical OR  (10==20 || 20==33) = false&lt;br&gt;
!   Logical Not !(10==20) = true&lt;/p&gt;

&lt;p&gt;Assignment Operators: &lt;br&gt;
The following operators are known as JavaScript assignment operators.&lt;br&gt;
Operator    Description Example&lt;br&gt;
=   Assign  10+10 = 20&lt;br&gt;
+=  Add and assign  var a=10; a+=20; Now a = 30&lt;br&gt;
-=  Subtract and assign var a=20; a-=10; Now a = 10&lt;br&gt;
&lt;em&gt;=  Multiply and assign var a=10; a&lt;/em&gt;=20; Now a = 200&lt;br&gt;
/=  Divide and assign   var a=10; a/=2; Now a = 5&lt;br&gt;
%=  Modulus and assign  var a=10; a%=2; Now a = 0&lt;/p&gt;

&lt;p&gt;Java Script Special Operators&lt;br&gt;
The following Operators are known as JavaScript Special operators.&lt;/p&gt;

&lt;p&gt;(?:) : Conditional Operator returns Value based on&lt;br&gt;
the Condition. It is like if- else. Comma Operator allows multiple expressions to be evaluated as single statement.&lt;/p&gt;

&lt;p&gt;Delete: Delete Operator deletes a property from the object.&lt;/p&gt;

&lt;p&gt;In: In Operator checks if object has the given property.&lt;/p&gt;

&lt;p&gt;Instanceof: Checks if the object is an instance of given type&lt;/p&gt;

&lt;p&gt;New:    Creates an instance&lt;/p&gt;

&lt;p&gt;Typeof: Checks the type of object .&lt;/p&gt;

&lt;p&gt;Void : it discards the expression's return value. &lt;br&gt;
Yield: checks what is returned in a generator by the generator's interator.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>JavaScript</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Fri, 02 Feb 2024 13:49:29 +0000</pubDate>
      <link>https://dev.to/mern_practical/javascript-5anf</link>
      <guid>https://dev.to/mern_practical/javascript-5anf</guid>
      <description>&lt;p&gt;&lt;code&gt;const a = 10;&lt;br&gt;
    function f() {&lt;br&gt;
       var/let a = 9&lt;br&gt;
        console.log(a)&lt;br&gt;
    }&lt;br&gt;
    f();//9&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It seems there's a small error in your code. The correct code snippet would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Copy&lt;/span&gt; &lt;span class="nx"&gt;code&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Output: 9&lt;/span&gt;
&lt;span class="nx"&gt;In&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt; &lt;span class="nx"&gt;corrected&lt;/span&gt; &lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The constant variable a is declared outside the function f with a value of 10.&lt;br&gt;
Inside the function f, a new variable a is declared using the let keyword, and it has a value of 9.&lt;br&gt;
The console.log(a) statement inside the function will print the value of the local variable a, which is 9.&lt;br&gt;
When you call the function f() at the end, it prints 9 to the console.&lt;br&gt;
If you intended to use var instead of let, the corrected code would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Copy&lt;/span&gt; &lt;span class="nx"&gt;code&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Output: 9&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both versions are valid, but using let is generally recommended for declaring block-scoped variables in modern JavaScript.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>JavaScript Errors</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Fri, 02 Feb 2024 13:39:38 +0000</pubDate>
      <link>https://dev.to/mern_practical/javascript-errors-di5</link>
      <guid>https://dev.to/mern_practical/javascript-errors-di5</guid>
      <description>&lt;p&gt;&lt;strong&gt;JavaScript Comment&lt;/strong&gt;&lt;br&gt;
The JavaScript comments are meaningful way to deliver message. It is used to add information about the code, Warnings or Suggestions.&lt;/p&gt;

&lt;p&gt;So that end user can easily interpret(understand) the code.&lt;br&gt;
The Java Script comment is ignored by the JavaScript engine i.e. embedded in the browser.&lt;/p&gt;

&lt;p&gt;Advantages of JavaScript Comments.&lt;/p&gt;

&lt;p&gt;There are mainly two advantages of JS comments.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To make Code easy to understand.&lt;/li&gt;
&lt;li&gt;To avoid the unnecessary code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;JS variables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Variable can store some information, we can use that information later &lt;br&gt;
We can change that information later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules for naming the variables:&lt;/strong&gt;&lt;br&gt;
Name must start with a letter (a to z ), underscore or dollar sign&lt;br&gt;
After first letter we can use digit (0 to 9)&lt;br&gt;
JavaScript variable case sensitive &lt;br&gt;
Cannot start with numbers :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Eg. 1value (invalid)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can only use dollar symbol or (under score) to define the variable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;E.g. _value  OR $value (both valid)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Js local variable : it is declared inside block or function .it is accessible within function or block only.&lt;/p&gt;

&lt;p&gt;Js global variable :it is accessible from any function. A variable that declared outside the function or declared with window object is known as global variable. &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;var : The var is the oldest keyword to declare a variable in *&lt;/em&gt;&lt;br&gt;
JavaScript. &lt;br&gt;
Scope: Global scoped or function scoped. The scope of the var keyword is the global or function scope. It means variables defined outside the function can be accessed globally, and variables defined inside a particular function can be accessed within the function. &lt;/p&gt;

&lt;p&gt;Example 1: Variable ‘a’ is declared globally. So, the scope of the variable ‘a’ is global, and it can be accessible everywhere in the program. The output shown is in the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    var a = 10
        function f(){
            console.log(a)
        }
    f();
    console.log(a);
&amp;lt;/script&amp;gt;
Output: 

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

&lt;/div&gt;



&lt;p&gt;**Example 2: **The variable ‘a’ is declared inside the function. If the user tries to access it outside the function, it will display the error. Users can declare the 2 variables with the same name using the var keyword. Also, the user can reassign the value into the var variable. The output shown in the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    function f() {
         // It can be accessible any
        // where within this function
        var a = 10;
        console.log(a)
    }
    f(); 
    // A cannot be accessible outside of function
    console.log(a);
&amp;lt;/script&amp;gt;
Output:

10
ReferenceError: a is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example 3:&lt;/strong&gt; we can re-declare variable using var and we can update var variable. The output is shown in the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt; 
    var a = 10
       // User can re-declare
    // variable using var
    var a = 8
     // User can update var variable
    a = 7
&amp;lt;/script&amp;gt;
Output:
7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**example 4: **If users use the var variable before the declaration, it initializes with the undefined value. The output is shown in the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    console.log(a);
    var a = 10; 
&amp;lt;script&amp;gt;g 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;============================================================&lt;br&gt;
let keyword in JavaScript: The let keyword is an improved version of the var keyword. &lt;/p&gt;

&lt;p&gt;Scope: block scoped: The scope of a let variable is only block scoped. It can’t be accessible outside the particular block ({block}). Let’s see the below example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt; The output is shown in the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    let a = 10;
    function f() {
        let b = 9
        console.log(b);
        console.log(a);
    }
    f();
&amp;lt;/script&amp;gt;
Output:

9
10
///////////////////////////////////////////////////////////////////Var 
    {// this is a block 
       var a = 10;
        console.log(a)
    }
   console.log(a)/////
&amp;gt; 10
&amp;gt; 10
/////////////////////////////////////////////////////00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 2: The code returns an error because we are accessing the let variable outside the function block.  The output is shown in the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    let a = 10;
    function f() {
        if (true) {
            let b = 9

            // It prints 9
            console.log(b);
        } 
        // It gives error as it
        // defined in if block
        console.log(b);
    }
    f()
    console.log(a)    // It prints 10
&amp;lt;/script&amp;gt;
Output:
9
ReferenceError: b is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 3: we cannot re-declare the variable defined with the let keyword but can update it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt; 
    let a = 10 
    // It is not allowed
    let a = 10

    // It is allowed
    a = 4
&amp;lt;/script&amp;gt;
Output:

Uncaught SyntaxError: Identifier 'a' has already been declared
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 4: we can declare the variable with the same name in different blocks using the let keyword.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
  let a = 10
  if (true) {
    let a=9
    console.log(a) // It prints 9
  }
  console.log(a) // It prints 10t5re
&amp;lt;/script&amp;gt;
Output:

9 
10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 5: If we use the let variable before the declaration, it does not initialize with undefined just like a var variable and return an error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    console.log(a);
    let a = 10;
&amp;lt;/script&amp;gt;
Output:

Uncaught ReferenceError: Cannot access 'a' before initialization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;const keyword in JavaScript: The const keyword has all the properties that are the same as the let keyword, except the user cannot update it.&lt;/p&gt;

&lt;p&gt;Scope: block scoped: When users declare a const variable, they need to initialize it, otherwise, it returns an error. The user cannot update the const variable once it is declared. &lt;/p&gt;

&lt;p&gt;Example 1: We are changing the value of the const variable so that it returns an error. The output is shown in the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    const a = 10;
    function f() {
        a = 9
[]7
        console.log(a)
    }
    f();
&amp;lt;/script&amp;gt;
Output:
a=9
TypeError:Assignment to constant variable.
&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;////////////////////
  const a = 10;
    function f() {
       const a = 9
        console.log(a)
    }
    f();//&amp;gt;9
///////////////////////////////////
&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;const a = 10;
    function f() {
       var/let a = 9
        console.log(a)
    }
    f();//9
////////////////////////////////////////
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 2: Users cannot change the properties of the const object, but they can change the value of properties of the const object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    const a = {
        prop1: 10,
        prop2: 9
    }

    // It is allowed
    a.prop1 = 3

    // It is not allowed
    a = {
        b: 10,
        prop2: 9
    }
&amp;lt;/script&amp;gt;
Output:

Uncaught SyntaxError:Unexpected identifier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>JavaScript Question</title>
      <dc:creator>MERN Practical Explanation</dc:creator>
      <pubDate>Fri, 02 Feb 2024 13:31:22 +0000</pubDate>
      <link>https://dev.to/mern_practical/javascript-question-1ai4</link>
      <guid>https://dev.to/mern_practical/javascript-question-1ai4</guid>
      <description>&lt;p&gt;&lt;strong&gt;Q1 What is JavaScript:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript is used to create client-side dynamic pages.&lt;/li&gt;
&lt;li&gt;JavaScript is object-based scripting language which is lightweight and cross-platform. &lt;/li&gt;
&lt;li&gt;JavaScript is an object-based scripting language, meaning it uses objects to represent data and functionality, rather than using simple variables and functions. This makes it easier to write and manage complex applications.&lt;/li&gt;
&lt;li&gt;JavaScript is considered lightweight because it is easy to learn and its syntax is simple, which means it is well-suited for small to medium-sized web applications.&lt;/li&gt;
&lt;li&gt; It is also cross-platform, which means it can be run on any device that has a web browser, making it a popular choice for web development.&lt;strong&gt;js is not compiled language .&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A programming language is a type of computer language that consists of a set of instructions for communicating with computers. &lt;/p&gt;

&lt;p&gt;A scripting language is a kind of programming language that is used to automate the execution of operations in a runtime environment.&lt;/p&gt;

&lt;p&gt;A script or scripting language is a computer language that does not need&lt;br&gt;
 the compilation step and is rather interpreted one by one at runtime.&lt;/p&gt;

&lt;p&gt;the programming languages that are compiled first before running, scripting languages do not compile the file and execute the file without being compiled.&lt;/p&gt;

&lt;p&gt;Scripting languages are used on the server-side as well as the client-side and are also widely used in web applications. The languages like JavaScript, Python, PHP, and Perl are examples of server-side scripting languages, and JavaScript, jQuery, AJAX are examples of client-side scripting languages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is meant by interpreted programming language?&lt;/strong&gt;&lt;br&gt;
An interpreted language is a programming language whose implementations execute instructions directly and freely, &lt;br&gt;
without previously compiling a program into machine-language&lt;br&gt;
instructions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Typed language?&lt;/strong&gt;&lt;br&gt;
Typed Language is in which the values are associated with values and not with variables. It is of two types:&lt;br&gt;
&lt;strong&gt;Dynamically:&lt;/strong&gt; in this, the variable can hold multiple types; like in JavaScript, a variable can take number, chars ,object.&lt;br&gt;
&lt;strong&gt;Statically:&lt;/strong&gt; in this, the variable can hold only one type, like in Java a variable declared of string can take only set of characters and nothing else.&lt;/p&gt;

&lt;p&gt;JavaScript follow synchronous pattern&lt;/p&gt;

&lt;p&gt;JavaScript code is a single thread, which means that code can only do one task at a time.&lt;/p&gt;

&lt;p&gt;A single-threaded process is the execution of programmed instructions in a single sequence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;. Dynamic Typing&lt;/strong&gt;&lt;br&gt;
JavaScript supports dynamic typing which means types of the variable are defined based on the stored value. For example, if we declare a variable x then we can store either a string or a Number type value or an array or an object. This is known as dynamic typing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is JavaScript a case-sensitive language?&lt;/strong&gt;&lt;br&gt;
Yes, JavaScript is a case sensitive language.  The language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.&lt;/p&gt;

&lt;p&gt;Since JavaScript is a loosely(dynamically) typed language, variables in JS are not associated with any type. A variable can hold the value of any data type.&lt;br&gt;
For example, a variable which is assigned a number type can be converted to a string type:&lt;br&gt;
var a = 23;&lt;br&gt;
var a = "Hello World!";&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) Advantages:/feature.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All popular web browser support JavaScript as they provided built in execution environment.&lt;br&gt;
js follow the syntax and structure of the c programming language. Thus it is a structured programming language&lt;br&gt;&lt;br&gt;
JavaScript is a lightweight scripting language because it is made for data handling at the browser only.&lt;br&gt;
Server interaction is less&lt;br&gt;
Feedback to the visitors is immediate&lt;br&gt;
Interactivity is high&lt;br&gt;
Interfaces are rich&lt;br&gt;
Speed. Client-side JavaScript is very fast because it can be run immediately &lt;br&gt;
within the client-side browser.&lt;br&gt;
    The biggest advantage of JavaScript having a ability &lt;br&gt;
to support all modern browsers and produce an equivalent result&lt;br&gt;
Display date and time &lt;br&gt;
Dynamic drop down menus.&lt;/p&gt;

&lt;p&gt;3) Disadvantage:&lt;br&gt;
No support for multithreading&lt;br&gt;
No support for multiprocessing&lt;br&gt;
Reading and writing of files is not allowed&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between null &amp;amp; undefined?&lt;/strong&gt;&lt;br&gt;
Undefined means a variable has been declared but has not yet been assigned a value. On the other hand,&lt;br&gt;
 null is an assignment value. It can be assigned to a variable as a representation of no value. Also, undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object.&lt;/p&gt;

&lt;p&gt;Storing a value in a variable is called variable initialization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are undeclared and undefined variables?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.&lt;/p&gt;

&lt;p&gt;Undefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned.&lt;/p&gt;

&lt;p&gt;Types of functions: Named and Anonymous function in JavaScript???&lt;br&gt;
In JavaScript, there are two types of functions: named functions and anonymous functions.&lt;br&gt;
A named function is a function that has a name. It can be defined using the function keyword followed by the function name, a set of parentheses, and a set of curly braces that enclose the function's body.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Here&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;s an example of a named function:

function addNumbers(a, b) {
  return a + b;
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An anonymous function is a function that does not have a name. It can be defined using the function keyword, followed by a set of parentheses and a set of curly braces that enclose the function's body, without any function name. Anonymous functions are often used as callback functions, as function arguments or in immediately invoked function expressions (IIFE).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Here&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;s an example of an anonymous function:

let sum = function(a, b) {
  return a + b;
} 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that in the example above, the function is assigned to a variable (sum), so it can be invoked later by calling that variable as a function. Anonymous functions can also be immediately invoked by enclosing the function definition in parentheses followed by an additional set of parentheses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is an immediately invoked anonymous function.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in this case, the function is defined and invoked immediately without being assigned to a variable.&lt;br&gt;
Interactivity is high in JavaScript .. explain in simple&lt;/p&gt;

&lt;p&gt;ChatGPT&lt;br&gt;
In simple terms, "interactivity" refers to how much a user can interact with a web page or application. JavaScript is a programming language that is commonly used in web development to add interactivity to websites.&lt;br&gt;
With JavaScript, we can create interactive features such as drop-down menus, pop-up windows, sliders, animations, and more. These features can respond to user actions such as clicks, mouse movements, or keyboard inputs, allowing users to interact with the website and its content in meaningful ways.&lt;br&gt;
For example, with JavaScript, a user can click a button to show or hide content on a web page, or drag and drop items to rearrange them. JavaScript can also be used to validate form inputs, perform calculations, and even create interactive games.&lt;br&gt;
Overall, JavaScript's ability to add interactivity to web pages is a key reason why it is such a popular programming language for web development.&lt;br&gt;
&lt;strong&gt;JavaScript is a programming language .explain&lt;/strong&gt; &lt;br&gt;
ChatGPT&lt;br&gt;
Yes, JavaScript is a programming language that is used primarily for web development, but can also be used for other purposes such as server-side programming, desktop applications, and mobile app development.&lt;/p&gt;

&lt;p&gt;One of the main uses of JavaScript is to create dynamic and interactive websites. JavaScript can be used to manipulate the content and styling of a web page, add interactivity through event handling, and communicate with web servers to update content without requiring a full page refresh.&lt;br&gt;
Overall, JavaScript is a versatile programming language that is widely used for a variety of applications, and its popularity and importance in web development continues to grow.&lt;/p&gt;

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