<?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: ajidk</title>
    <description>The latest articles on DEV Community by ajidk (@ajidk16).</description>
    <link>https://dev.to/ajidk16</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%2F333775%2Fc2bf7a61-717d-4de5-b127-c28c8cae9997.jpeg</url>
      <title>DEV Community: ajidk</title>
      <link>https://dev.to/ajidk16</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ajidk16"/>
    <language>en</language>
    <item>
      <title>How to make an effect typewriter</title>
      <dc:creator>ajidk</dc:creator>
      <pubDate>Fri, 10 Feb 2023 13:29:48 +0000</pubDate>
      <link>https://dev.to/ajidk16/how-to-make-an-effect-typewriter-nl6</link>
      <guid>https://dev.to/ajidk16/how-to-make-an-effect-typewriter-nl6</guid>
      <description>&lt;p&gt;When I first opened chatgpt, I was interested in seeing typewriters, and then I became curious about typewriters and searched for various sources. Using Javascript, I try to implement this. and then&lt;/p&gt;

&lt;h2&gt;
  
  
  What is typewriter
&lt;/h2&gt;

&lt;p&gt;A typewriter is a mechanical device that is used to type text on a screen. Several keypad buttons have letters, numbers, and symbols on their surfaces, which are pressed to write characters on a screen that moves beneath the rollers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Typewriters: why use them
&lt;/h2&gt;

&lt;p&gt;By making visitors focus on a single character for a designated period of time, this effect can enhance user engagement with web content and the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

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

&lt;h2&gt;
  
  
  code
&lt;/h2&gt;

&lt;p&gt;Here's an example of how you can create a typewriter effect in React:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a state to store the current text to be displayed on the screen:
&lt;/li&gt;
&lt;/ol&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;displayedContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setDisplayedContent&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&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;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIndex&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create an variable content &amp;amp; speed to store the texts that you want to display one by one:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;please visit suraji.my.id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;speed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Use the useEffect hook to handle the animation:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;setInterval&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;setIndex&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;index&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;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;content&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;-&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="nf"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animKey&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;index&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;index&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="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;speed&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;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;speed&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&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="nf"&gt;setDisplayedContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;displayedContent&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;displayedContent&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&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;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&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;Use the state in your component's render method to display the current text:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&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;displayedContent&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will display the texts one by one with a typing effect, with a delay of 100ms pause between each text. You can adjust the delay and pause times to suit your needs.&lt;/p&gt;

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

&lt;p&gt;By making visitors focus on a single character for a designated period of time, this effect can enhance user engagement with web content and the page.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>mcp</category>
      <category>api</category>
      <category>help</category>
    </item>
    <item>
      <title>Disable notification in vercel</title>
      <dc:creator>ajidk</dc:creator>
      <pubDate>Wed, 08 Feb 2023 03:12:49 +0000</pubDate>
      <link>https://dev.to/ajidk16/disable-notification-in-vercel-58fm</link>
      <guid>https://dev.to/ajidk16/disable-notification-in-vercel-58fm</guid>
      <description>&lt;p&gt;Do you use Vercel? I am a user of Vercel. When I deploy, I receive a notification in my email every time. this causes a lot of spam in my email. I have found a solution to this problem, &lt;br&gt;
You can create a file called &lt;code&gt;vercel.json&lt;/code&gt; in your project:&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;github&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;silent&lt;/span&gt;&lt;span class="dl"&gt;"&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="c1"&gt;// if you use gitlab&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gitlab&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;silent&lt;/span&gt;&lt;span class="dl"&gt;"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank you for reading. I hope it was useful.&lt;/p&gt;

</description>
      <category>deploy</category>
      <category>vercel</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Debouncing: how to use it</title>
      <dc:creator>ajidk</dc:creator>
      <pubDate>Sun, 05 Feb 2023 00:13:52 +0000</pubDate>
      <link>https://dev.to/ajidk16/debouncing-how-to-use-it-b7m</link>
      <guid>https://dev.to/ajidk16/debouncing-how-to-use-it-b7m</guid>
      <description>&lt;h2&gt;
  
  
  What is debouncing?
&lt;/h2&gt;

&lt;p&gt;Debouncing is a technique used in electronic systems to filter out transient electrical noise from an input signal. It is used to ensure that only one valid signal is received by the system even if multiple unstable or false signals are received in a short period of time. Debouncing helps maintain the stability and performance of the system and minimizes problems caused by noise. This technique is widely used in microcontroller-based systems, such as those in computer keyboards, push-button switches, and other digital inputs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of debouncing
&lt;/h2&gt;

&lt;p&gt;using debouncing has several advantages, inclunding :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improved system stability: Debouncing helps eliminate false signals and ensures that only one valid signal is received by the system, thereby improving its stability and performance.&lt;/li&gt;
&lt;li&gt;Reduced processing load: By filtering out noise, debouncing reduces the processing load on the system, freeing up resources for other tasks.&lt;/li&gt;
&lt;li&gt;Better user experience: Debouncing is commonly used in user interfaces, such as keyboards and buttons, to improve the user experience by ensuring that rapid inputs are registered only once.&lt;/li&gt;
&lt;li&gt;Increased system reliability: By filtering out false signals, debouncing can increase the reliability of the system, reducing the likelihood of errors or malfunctions.&lt;/li&gt;
&lt;li&gt;Easy implementation: Debouncing is a relatively simple technique to implement, and can be easily integrated into existing systems to improve their performance and reliability.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Disadvantages of debouncing
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Increased latency: By delaying the processing of signals, debouncing can increase latency, or the time it takes for a signal to be processed and acted upon.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increased complexity: Depending on the implementation, debouncing can add complexity to the system, making it more difficult to debug and maintain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduced responsiveness: In some cases, debouncing can reduce the responsiveness of the system, as it may take some time for a signal to be processed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increased power consumption: The use of additional components, such as timers or counters, to implement debouncing can increase power consumption and reduce battery life in battery-powered systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduced sensitivity: Debouncing can also reduce the sensitivity of the system, as it may filter out valid signals that are close together in time.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's important to consider these disadvantages when deciding whether or not to use debouncing in a particular system, and to carefully balance the trade-offs between performance, reliability, and responsiveness.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example code with React
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&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="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&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;const&lt;/span&gt; &lt;span class="nx"&gt;DebouncedInput&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;timerId&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;()&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;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timerId&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleInputChange&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="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;newValue&lt;/span&gt; &lt;span class="o"&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;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nf"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timerId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;timerId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&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;// Perform the action here&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="s2"&gt;`Debounced value: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;value&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="mi"&gt;500&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;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleInputChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&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;DebouncedInput&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;In conclusion, using debouncing can have several benefits, including improved system stability, reduced processing load, better user experience, increased system reliability, and ease of implementation. However, it also has some disadvantages, such as increased latency, increased complexity, reduced responsiveness, increased power consumption, and reduced sensitivity.&lt;/p&gt;

</description>
      <category>motivation</category>
      <category>productivity</category>
      <category>challenge</category>
    </item>
    <item>
      <title>How toAdd Google Analytics to Next.js</title>
      <dc:creator>ajidk</dc:creator>
      <pubDate>Fri, 26 Aug 2022 14:01:27 +0000</pubDate>
      <link>https://dev.to/ajidk16/how-toadd-google-analytics-to-nextjs-11i1</link>
      <guid>https://dev.to/ajidk16/how-toadd-google-analytics-to-nextjs-11i1</guid>
      <description>&lt;p&gt;The implementation is straightforward and doesn't require any third-party library.&lt;/p&gt;

&lt;p&gt;you will need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a Next.Js project&lt;/li&gt;
&lt;li&gt;a Google Analytics account&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1 Add your google analytics id to your project .env.local file.&lt;/p&gt;

&lt;p&gt;First, start with creating a .env.local file where you will place your Google Analytics key.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Tip: Check your .gitignore to make sure that you don't commit this file by accident. .env.local should have already been included by default in your Next.js project but check to make sure.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NEXT_PUBLIC_GOOGLE_ANALYTICS=&amp;lt;Your_tracking_ID&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2 Inject Google Analytics tracking code into your project application.&lt;/p&gt;

&lt;p&gt;Now that your key is set, you need to inject and configure Google Analytics' Global site tag (aka gtag) into your browser window.&lt;/p&gt;

&lt;p&gt;To access the head element in your Next.js application, you need to create a custom _document.js file into your pages folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Document, { Html, Head, Main, NextScript } from 'next/document'

export default class MyDocument extends Document {
  render() {
    return (
      &amp;lt;Html&amp;gt;
        &amp;lt;Head&amp;gt;
          &amp;lt;script
            async
            src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}`}
          /&amp;gt;
          &amp;lt;script
            dangerouslySetInnerHTML={{
              __html: `
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());
            gtag('config', '${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}', {
              page_path: window.location.pathname,
            });
          `,
            }}
          /&amp;gt;
        &amp;lt;/Head&amp;gt;
        &amp;lt;body&amp;gt;
          &amp;lt;Main /&amp;gt;
          &amp;lt;NextScript /&amp;gt;
        &amp;lt;/body&amp;gt;
      &amp;lt;/Html&amp;gt;
    )
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3 Custom functions to track pageviews and events.&lt;/p&gt;

&lt;p&gt;Let's move on to the tracking piece of Google Analytics. In order to correctly track your user's behaviours, you will need to log page views and optionally, specific events triggered in your application.&lt;/p&gt;

&lt;p&gt;Inside your lib/ga folder, create an index.js with two functions: one to log pageviews and the other events.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// log the pageview with their URL
export const pageview = (url) =&amp;gt; {
  window.gtag('config', process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS, {
    page_path: url,
  })
}

// log specific events happening.
export const event = ({ action, params }) =&amp;gt; {
  window.gtag('event', action, params)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;lib/ga/index.js&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;4 Log pageviews in your project app.&lt;/p&gt;

&lt;p&gt;The simplest way to log pageviews in your Next.js app is to subscribe to your router and listen for the routeChangeComplete event.&lt;/p&gt;

&lt;p&gt;To do so, go into your _app.js file and with useEffect, check for new events happening with your router. There are many types of events but we only care when users navigate to a new page successfully (routeChangeComplete).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useEffect } from 'react'
import { useRouter } from 'next/router'

import * as ga from '../lib/ga'

function MyApp({ Component, pageProps }) {
  const router = useRouter()

  useEffect(() =&amp;gt; {
    const handleRouteChange = (url) =&amp;gt; {
      ga.pageview(url)
    }
    //When the component is mounted, subscribe to router changes
    //and log those page views
    router.events.on('routeChangeComplete', handleRouteChange)

    // If the component is unmounted, unsubscribe
    // from the event with the `off` method
    return () =&amp;gt; {
      router.events.off('routeChangeComplete', handleRouteChange)
    }
  }, [router.events])

  return &amp;lt;Component {...pageProps} /&amp;gt;
}

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

&lt;/div&gt;



&lt;p&gt;5 Log specific events in your project app.&lt;/p&gt;

&lt;p&gt;Now that our page views are tracked, you may be interested in logging specific events in your application. Here is a list of Google Analytics Default events.&lt;br&gt;
&lt;/p&gt;

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

import * as ga from '../lib/ga'

export default function Home() {
  const [query, setQuery] = useState("");

  const search = () =&amp;gt; {
    ga.event({
      action: "search",
      params : {
        search_term: query
      }
    })
  }

  return (
    &amp;lt;div&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;input type="text" onChange={(event) =&amp;gt; setQuery(event.target.value)}&amp;gt;&amp;lt;/input&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div&amp;gt;
            &amp;lt;button onClick={() =&amp;gt; search()}&amp;gt;Search&amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Data Instances</title>
      <dc:creator>ajidk</dc:creator>
      <pubDate>Tue, 14 Jun 2022 01:36:01 +0000</pubDate>
      <link>https://dev.to/ajidk16/data-instances-39nn</link>
      <guid>https://dev.to/ajidk16/data-instances-39nn</guid>
      <description>&lt;p&gt;When a new piece of data is introduced into a JavaScript program, the program keeps track of it in an instance of that data type. An instance is an individual case of a data type.&lt;/p&gt;

&lt;h4&gt;
  
  
  Booleans
&lt;/h4&gt;

&lt;p&gt;Booleans are a primitive data type. They can be either &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;.&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;let&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Math.random()
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;Math.random()&lt;/code&gt; function returns a floating-point,random number between 0 (inclusive) and 1 (exclusive).&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="c1"&gt;// 0 - 0.9&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Math.floor()
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;Math.floor()&lt;/code&gt; functions returns largers less than or equal to a given number.&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;5.05&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Single Line Comment
&lt;/h4&gt;

&lt;p&gt;In JavaScript, single-line comments are created with two consecutive forward slashes &lt;code&gt;//&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// This line will donate a comment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Strings
&lt;/h4&gt;

&lt;p&gt;String are a primitive data type. They are any grouping of characters (letters, spaces, numbers, or symbols) surrounded by single quotes&lt;code&gt;'&lt;/code&gt; or double quotes &lt;code&gt;"&lt;/code&gt;.&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;let&lt;/span&gt; &lt;span class="nx"&gt;single&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Who am I&lt;/span&gt;&lt;span class="dl"&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;double&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Who am I&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Null
&lt;/h4&gt;

&lt;p&gt;Null is a primitive data type. It represents the intentional absence of value. In code, it is represented as &lt;code&gt;null&lt;/code&gt;.&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;let&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Arithmetic Operators
&lt;/h4&gt;

&lt;p&gt;JavaScript support arithmetic operators for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;+&lt;/code&gt; addition&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-&lt;/code&gt; subtraction&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;*&lt;/code&gt; multiplication&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/&lt;/code&gt; division&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;%&lt;/code&gt; module&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Multi-line Comments
&lt;/h4&gt;

&lt;p&gt;In JavaScript, multi-line comments are created by surrounding the lines with &lt;code&gt;/*&lt;/code&gt; at the beginning and &lt;code&gt;*/&lt;/code&gt; at the end. Comments are good ways for a variety of reasons like explaining a code block or indicating some hints, etc.&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="cm"&gt;/*
Multi line comment must be
changed before deployment.
*/&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;baseUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://ajidk.vercel.app/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Remainder / Modulo Operator
&lt;/h4&gt;

&lt;p&gt;The remainder operator, sometimes called modulo, returns the number that remains after the right-hand number divides into the left-hand number as many times as it evenly can.&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;// calculates # of weeks in a year, rounds down to&lt;/span&gt;
&lt;span class="nx"&gt;nearest&lt;/span&gt; &lt;span class="nx"&gt;integer&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;weeksInYear&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;365&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// calculates the number of days left over after 365 is&lt;/span&gt;
&lt;span class="nx"&gt;divides&lt;/span&gt; &lt;span class="nx"&gt;by&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;daysLeftOver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;365&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&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;A year has &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;weeksInYear&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; weeks and &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; 
&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;daysLeftOver&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; days&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  String Interpolation
&lt;/h4&gt;

&lt;p&gt;String interpolation is the process of evaluating string literals containing one or more placeholders (expressions, variables, etc)&lt;br&gt;
It can be performed using template literals:&lt;br&gt;
&lt;code&gt;text $(expression) text&lt;/code&gt;&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;let&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;

&lt;span class="c1"&gt;// String concatenation&lt;/span&gt;
&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Tommy is &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; years old.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// String interpolation&lt;/span&gt;
&lt;span class="s2"&gt;`Tommy is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; years old.`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Assignment Operators
&lt;/h4&gt;

&lt;p&gt;An assignment operator assigns a value to its left operand based on the value of its right operand. Here are some of them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;+=&lt;/code&gt; addition assignment&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-&lt;/code&gt; subtraction assignment&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;*&lt;/code&gt; multiplication assignment&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/&lt;/code&gt; division assignment&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;%&lt;/code&gt; module assignment
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;

&lt;span class="c1"&gt;// Both statements will add 10&lt;/span&gt;
&lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 120&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Variables
&lt;/h4&gt;

&lt;p&gt;Variables are used whenever there's a need to store a piece of data. A variable contains data that can be used in the program elsewhere. Using variables also ensures code re-usability since it can be used to replace the same value in multiple places.&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;currency&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;userIncome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;85000&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currency&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;userIncome&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; is more than the average income.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// $85000 is more than the average income.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Undefined
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;undefined&lt;/code&gt; is a primitive JavaScript value that represents lack of defined value. Variables that are declared but not initialized to a value will have the value &lt;code&gt;undefined&lt;/code&gt;.&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;var&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&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="c1"&gt;// undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Template Literals
&lt;/h4&gt;

&lt;p&gt;Template literals are strings that allow embedded expressions, &lt;code&gt;${expression}&lt;/code&gt;. While regular strings use single &lt;code&gt;'&lt;/code&gt; or double &lt;code&gt;"&lt;/code&gt; quotes, template literals use backticks instead.&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;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Ajidk&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello, &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="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Hello, Ajidk&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`John is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="mi"&gt;10&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="s2"&gt; years old.`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// John is 16 years old.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Learn JavaScript: Variables
&lt;/h4&gt;

&lt;p&gt;A variable is a container for data that is stored in computer memory. It is referenced by a descriptive name that a programmer can call to assign a specific value and retrieve it.&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;// examples of variables&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Tammy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;found&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&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="nx"&gt;found&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Tammy, false, 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Declaring Variables
&lt;/h4&gt;

&lt;p&gt;To declare a variable in JavaScript, any of these 3 keywords can be used along with a variable name:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; is used in pre-ES6 versions of JavaScript.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;let&lt;/code&gt; is the preferred way to declare a variable when it can be reassigned.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;const&lt;/code&gt; is the preferred way to declare a variable with a constant value.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;age&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;weight&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;numberOfFingers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  let Keyword
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;let&lt;/code&gt; creates a local variable in JavaScript &amp;amp; can be-re-assigned. Initialization during the declaration of a &lt;code&gt;let&lt;/code&gt; variable is optional. A &lt;code&gt;let&lt;/code&gt; variable will contain &lt;code&gt;undefined&lt;/code&gt; if nothing is assigned to it.&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;let&lt;/span&gt; &lt;span class="nx"&gt;count&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// undefined&lt;/span&gt;
&lt;span class="nx"&gt;count&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  const Keyword
&lt;/h4&gt;

&lt;p&gt;A constant variable can be declared using the keyword &lt;code&gt;const&lt;/code&gt;.It must have an assignment. Any attempt of re-assigning a &lt;code&gt;const&lt;/code&gt; variable will result in JavaScript runtime error.&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;number&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  String Concatenation
&lt;/h4&gt;

&lt;p&gt;In JavaScript, multiple strings can be concatenated together using the &lt;code&gt;+&lt;/code&gt; operator. In the example, multiple string and variables containing string values have been concatenated. After execution of the code block, the &lt;code&gt;displayText&lt;/code&gt; variable will contain the concatenated string.&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;let&lt;/span&gt; &lt;span class="nx"&gt;service&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;say bismillah bree&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;May 20th&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;displayText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;oh my friends &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;service&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; so that life is blessed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;displayText&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// oh my friend say bismillah bree so that life is blessed.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Introduction JavaScript</title>
      <dc:creator>ajidk</dc:creator>
      <pubDate>Thu, 09 Jun 2022 07:48:30 +0000</pubDate>
      <link>https://dev.to/ajidk16/introduction-javascript-1d0k</link>
      <guid>https://dev.to/ajidk16/introduction-javascript-1d0k</guid>
      <description>&lt;h3&gt;
  
  
  console.log()
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;console.log&lt;/code&gt; method is used to log or print messages to the console. It can also be used to print objects and other info.&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello World!`); // Hello World!
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  JavaScript
&lt;/h3&gt;

&lt;p&gt;JavaScript is a programming language that powers the dynamyc behavior on most websites. Alongside HTML and CSS, it is a core technology that makes the web run.&lt;/p&gt;

&lt;h3&gt;
  
  
  Methods
&lt;/h3&gt;

&lt;p&gt;Methods return information about an object, and are called by appending an instance with a period&lt;code&gt;.&lt;/code&gt;, the method name, and parentheses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Libraries
&lt;/h3&gt;

&lt;p&gt;Libraries contain methods that can be called by appending the library name with a period &lt;code&gt;.&lt;/code&gt;, the method name, and set of parentheses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Numbers
&lt;/h3&gt;

&lt;p&gt;Numbers are a primitive data type. They include the set of all integers and floating point numbers.&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;let&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16000&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;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;80000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  String.length
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;.length&lt;/code&gt; property of a string returns the number of characters that make up the string.&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;let&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello daddy!&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 12&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sugar&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;JavaScript arrays have quite a lot of useful methods that can simplify our development efforts.Knowing these methods can save us time and can even boost the performance of our code.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Javascript Variable</title>
      <dc:creator>ajidk</dc:creator>
      <pubDate>Thu, 02 Jun 2022 10:00:03 +0000</pubDate>
      <link>https://dev.to/ajidk16/javascript-variable-1ff1</link>
      <guid>https://dev.to/ajidk16/javascript-variable-1ff1</guid>
      <description>&lt;p&gt;4 ways to Declare a Javascript Variable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;using &lt;code&gt;var&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;using &lt;code&gt;let&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;using &lt;code&gt;const&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;using &lt;code&gt;nothing&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What are Variables?
&lt;/h3&gt;

&lt;p&gt;Variable are container for storing data&lt;/p&gt;

&lt;p&gt;example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var x = 5;
var y = 6;
var z = x + y;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  When to Use JavaScript var?
&lt;/h3&gt;

&lt;p&gt;Always declare Javascript variables with &lt;code&gt;var&lt;/code&gt;,&lt;code&gt;let&lt;/code&gt; or &lt;code&gt;const&lt;/code&gt;.&lt;br&gt;
the &lt;code&gt;var&lt;/code&gt; keyword is used in all JavaScript code from 1995 to 2015.&lt;br&gt;
the &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; keywords were added to JavaScript in 2015.&lt;br&gt;
if you want your code to run in older browser, you must use &lt;code&gt;var&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  When to Use JavaScript const?
&lt;/h3&gt;

&lt;p&gt;if you want a general rules: always declare variables with &lt;code&gt;const&lt;/code&gt;.&lt;br&gt;
if you think the value of the variable can change, use &lt;code&gt;let&lt;/code&gt;.&lt;br&gt;
in this example, &lt;code&gt;price1&lt;/code&gt;,&lt;code&gt;price2&lt;/code&gt;, anda &lt;code&gt;total&lt;/code&gt;, are variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const price1 = 10;
const price2 = 20;
let total = price1 + price2; //30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;noted: the two variables &lt;code&gt;price1&lt;/code&gt; and &lt;code&gt;price2&lt;/code&gt; are declared with the &lt;code&gt;const&lt;/code&gt; keyword. there are constant values and cannot changed. the variable &lt;code&gt;total&lt;/code&gt; is declared with the &lt;code&gt;let&lt;/code&gt; keyword.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  JavaScript Identifiers
&lt;/h3&gt;

&lt;p&gt;All JavaScript &lt;strong&gt;variables&lt;/strong&gt; mus be &lt;strong&gt;identified&lt;/strong&gt; with &lt;strong&gt;unique names&lt;/strong&gt;.&lt;br&gt;
The general rules for constructing names for variables are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Names can contain letters, digits, underscores, and dollar signs.&lt;/li&gt;
&lt;li&gt;Names must begin with a letters.&lt;/li&gt;
&lt;li&gt;Names can also begin with $ and _.&lt;/li&gt;
&lt;li&gt;names are case sensitive(a and A different variables).&lt;/li&gt;
&lt;li&gt;reserved words cannot be used as names.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  The Assignment operator
&lt;/h3&gt;

&lt;p&gt;In JavaScript, the equal sign(&lt;code&gt;=&lt;/code&gt;) is an assigment operator, not an &lt;code&gt;equal to&lt;/code&gt; operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;s = s + 16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Declaring a JavaScript Variable
&lt;/h3&gt;

&lt;p&gt;You can declare a JavaScript variable with the &lt;code&gt;var&lt;/code&gt; or the &lt;code&gt;let&lt;/code&gt; keyword:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var carName;
or
let carName;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  One Statement, Many Variables
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name='aji', lastName='dk',address:'Indonesia'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Value = undefined
&lt;/h3&gt;

&lt;p&gt;A variable declared without a value will have the value undefined.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>DRY “Don't Repeat Yourself”</title>
      <dc:creator>ajidk</dc:creator>
      <pubDate>Thu, 26 May 2022 02:30:47 +0000</pubDate>
      <link>https://dev.to/ajidk16/dry-dont-repeat-yourself-1l3o</link>
      <guid>https://dev.to/ajidk16/dry-dont-repeat-yourself-1l3o</guid>
      <description>&lt;p&gt;DRY is a basic principle in any software development. Certainly, it is the most understandable software principle, but not everything is so obvious. I want to show you when you don’t need to follow this principle.&lt;/p&gt;

&lt;p&gt;DRY is an acronym, of “Don’t Repeat Yourself”. The main problem that DRY can solve is a reducing repetition of code. Sometimes you need to have already existed function in another module, class, etc. And the easiest way to do that is just copy&amp;amp;paste this function.Congratulations, DRY principle violated. Factual copping of code creates for you one huge problem:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It is hard to maintain all these functions on the whole project, and if you need to change this function — you should change it in all places where did you copy it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to reduce DRY&lt;/strong&gt;&lt;br&gt;
the key points for how to apply abstraction to write code that doesn’t repeat itself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create functions for common software patterns. We call them &lt;em&gt;higher order function&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Replace the boilerplate in your code with higher order funcitons.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some examples of higher order functions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;map&lt;/code&gt; --- modifying each element in the array based on give rule
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const finalParticipants = ["Taylor", "Donald", "Don"];

// add string after each final participant
const announcements = finalParticipants.map((member) =&amp;gt; {
  return member + " joined the contest.";
});

console.log(announcements);
// [
//   "Taylor joined the contest.",
//   "Donald joined the contest.",
//   "Don joined the contest.",
// ];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;filter&lt;/code&gt; --- getting subset of the array the passes a given criterion
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const randomNumbers = [4, 11, 42, 14, 39];
const filteredArray = randomNumbers.filter((n) =&amp;gt; {
  return n &amp;gt; 5;
});
console.log(filteredArray); //[ 11, 42, 14, 39 ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;reduce&lt;/code&gt; --- combining everything in the array based on a given rule
&lt;/li&gt;
&lt;/ul&gt;

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

const sum = arrayOfNumbers.reduce((accumulator, currentValue) =&amp;gt; {  
  return accumulator + currentValue;
});

console.log(sum); // 10

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;forEach&lt;/code&gt; --- executes a callback function on each of the elements in an array in order.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [28, 77, 45];

numbers.forEach((number) =&amp;gt; {
  console.log(number);
  // 28
  // 77
  // 45
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Advantages of DRY&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maintainability&lt;/li&gt;
&lt;li&gt;Readability&lt;/li&gt;
&lt;li&gt;Reuse&lt;/li&gt;
&lt;li&gt;Cost&lt;/li&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages of DRY&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Not all code needs to be merged into one piece. Some times 2 pieces of code can look similar but with subtle differences.&lt;/li&gt;
&lt;li&gt;If the code is “over dried”, it becomes difficult to read and understand.&lt;/li&gt;
&lt;li&gt;Often missed, DRY is not to be limited to just the code. It is to be applied in equal measure to database design, documentation, testing code etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Yes, these codes are identical right now. Does the change of one duplicated part can affect some other duplicated part? If It isn’t — you can duplicate the code&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Uncontrolled textarea element</title>
      <dc:creator>ajidk</dc:creator>
      <pubDate>Thu, 19 May 2022 06:44:12 +0000</pubDate>
      <link>https://dev.to/ajidk16/uncontrolled-textarea-element-3f1d</link>
      <guid>https://dev.to/ajidk16/uncontrolled-textarea-element-3f1d</guid>
      <description>&lt;p&gt;Renders an uncontroller &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt; element that uses a callback function to pass its value to the parent component.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use the &lt;code&gt;defaultValue&lt;/code&gt; passed down from the parent as the uncontrolled input field's initial value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;use the &lt;code&gt;onChange&lt;/code&gt; event to fire the &lt;code&gt;onValueChange&lt;/code&gt; callback and send the new value to the parent.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qXtNt3zP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8d4l28ylrvwmjy8kgvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qXtNt3zP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8d4l28ylrvwmjy8kgvi.png" alt="Image description" width="880" height="830"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
    </item>
  </channel>
</rss>
