<?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: HARSHITH GADDAM</title>
    <description>The latest articles on DEV Community by HARSHITH GADDAM (@harshith_gaddam).</description>
    <link>https://dev.to/harshith_gaddam</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4039220%2F9859a55c-0f5a-4fe1-9c74-96e155044b54.jpg</url>
      <title>DEV Community: HARSHITH GADDAM</title>
      <link>https://dev.to/harshith_gaddam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harshith_gaddam"/>
    <language>en</language>
    <item>
      <title>My JavaScript Learning Journey: Call Back Hell &amp; Promises</title>
      <dc:creator>HARSHITH GADDAM</dc:creator>
      <pubDate>Tue, 04 Aug 2026 11:54:33 +0000</pubDate>
      <link>https://dev.to/harshith_gaddam/my-javascript-learning-journey-call-back-hell-promises-56b</link>
      <guid>https://dev.to/harshith_gaddam/my-javascript-learning-journey-call-back-hell-promises-56b</guid>
      <description>&lt;p&gt;Today I learned one of the most important concepts in JavaScript—&lt;strong&gt;asynchronous programming with Promises&lt;/strong&gt;. Initially, Promises seemed confusing, but after understanding how they work internally, the concept became much clearer.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What is Callback Hell?
&lt;/h2&gt;

&lt;p&gt;A callback is a function passed to another function that executes after an asynchronous operation completes.&lt;/p&gt;

&lt;p&gt;When multiple asynchronous operations depend on each other, callbacks become deeply nested.&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="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&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="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;getOrders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;getOrderDetails&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;orders&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;id&lt;/span&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="nx"&gt;details&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;processOrder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;details&lt;/span&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="nx"&gt;result&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="nx"&gt;result&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="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This deeply nested structure is called &lt;strong&gt;Callback Hell&lt;/strong&gt; or the &lt;strong&gt;Pyramid of Doom&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Problems with Callback Hell
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Difficult to read&lt;/li&gt;
&lt;li&gt;Hard to debug&lt;/li&gt;
&lt;li&gt;Difficult to maintain&lt;/li&gt;
&lt;li&gt;Error handling becomes complicated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To solve these problems, JavaScript introduced &lt;strong&gt;Promises&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. What is a Promise?
&lt;/h1&gt;

&lt;p&gt;A &lt;strong&gt;Promise&lt;/strong&gt; is an object that represents the eventual result of an asynchronous operation.&lt;/p&gt;

&lt;p&gt;It promises that it will either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complete successfully&lt;/li&gt;
&lt;li&gt;Fail with an error&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A Promise starts in the &lt;strong&gt;Pending&lt;/strong&gt; state and eventually becomes either &lt;strong&gt;Fulfilled&lt;/strong&gt; or &lt;strong&gt;Rejected&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  3. Promise States
&lt;/h1&gt;

&lt;p&gt;Every Promise has three possible states.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pending
&lt;/h3&gt;

&lt;p&gt;The asynchronous operation is still running.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fulfilled
&lt;/h3&gt;

&lt;p&gt;The operation completed successfully.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rejected
&lt;/h3&gt;

&lt;p&gt;The operation failed.&lt;/p&gt;

&lt;p&gt;A Promise can change its state only once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pending
   |
   | resolve()
   ▼
Fulfilled

OR

Pending
   |
   | reject()
   ▼
Rejected
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  4. Creating a Promise
&lt;/h1&gt;

&lt;p&gt;A Promise is created using the &lt;code&gt;Promise&lt;/code&gt; constructor.&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;promise&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;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&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="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One important thing I learned today is that &lt;strong&gt;I do not create &lt;code&gt;resolve&lt;/code&gt; and &lt;code&gt;reject&lt;/code&gt; myself.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript automatically provides these two functions to the Promise executor.&lt;/p&gt;

&lt;p&gt;Conceptually, it works like this:&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="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&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="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;resolve()&lt;/code&gt; is used when the operation succeeds.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;reject()&lt;/code&gt; is used when the operation fails.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  5. Using resolve() and reject()
&lt;/h1&gt;

&lt;p&gt;Example:&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;promise&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;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&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;marks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&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;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Pass&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Fail&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;If the condition is true, the Promise becomes &lt;strong&gt;Fulfilled&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Otherwise, it becomes &lt;strong&gt;Rejected&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  6. Handling Promises
&lt;/h1&gt;

&lt;h3&gt;
  
  
  then()
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;.then()&lt;/code&gt; executes only when the Promise is fulfilled.&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;promise&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;result&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;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;result&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;h3&gt;
  
  
  catch()
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;.catch()&lt;/code&gt; executes only when the Promise is rejected.&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;promise&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="o"&gt;=&amp;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="nx"&gt;error&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;h3&gt;
  
  
  finally()
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;.finally()&lt;/code&gt; executes whether the Promise succeeds or fails.&lt;/p&gt;

&lt;p&gt;It is useful for cleanup operations like hiding loading indicators or closing connections.&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;promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;finally&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;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;Finished&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;h1&gt;
  
  
  7. Promise Chaining
&lt;/h1&gt;

&lt;p&gt;Every &lt;code&gt;.then()&lt;/code&gt;, &lt;code&gt;.catch()&lt;/code&gt;, and &lt;code&gt;.finally()&lt;/code&gt; returns another Promise.&lt;/p&gt;

&lt;p&gt;This allows us to chain multiple asynchronous operations.&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="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&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;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&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;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&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;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;value&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;p&gt;Each &lt;code&gt;.then()&lt;/code&gt; receives the value returned by the previous &lt;code&gt;.then()&lt;/code&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  8. Error Propagation
&lt;/h1&gt;

&lt;p&gt;One of the most interesting concepts I learned today is &lt;strong&gt;Error Propagation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If an error occurs inside any &lt;code&gt;.then()&lt;/code&gt; callback, JavaScript automatically skips all remaining &lt;code&gt;.then()&lt;/code&gt; callbacks and jumps directly to the nearest &lt;code&gt;.catch()&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="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&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;value&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;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Something went wrong&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;span class="nf"&gt;then&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;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 will never execute&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;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="o"&gt;=&amp;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="nx"&gt;error&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="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Something went wrong
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes error handling much simpler because a single &lt;code&gt;.catch()&lt;/code&gt; can handle errors from multiple Promise operations.&lt;/p&gt;




&lt;h1&gt;
  
  
  9. Practical Promise Example
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&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="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&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;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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;harshith&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;password&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1234&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="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Login Successful&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Invalid Username or Password&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;span class="mi"&gt;2000&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;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;harshith&lt;/span&gt;&lt;span class="dl"&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;1234&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;message&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="o"&gt;=&amp;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;error&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example helped me understand when to call &lt;code&gt;resolve()&lt;/code&gt; and &lt;code&gt;reject()&lt;/code&gt; based on a condition.&lt;/p&gt;




&lt;h1&gt;
  
  
  10. Key Takeaways
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Callback Hell makes asynchronous code difficult to read and maintain.&lt;/li&gt;
&lt;li&gt;Promises solve Callback Hell by making asynchronous code cleaner.&lt;/li&gt;
&lt;li&gt;Every Promise has three states: &lt;strong&gt;Pending&lt;/strong&gt;, &lt;strong&gt;Fulfilled&lt;/strong&gt;, and &lt;strong&gt;Rejected&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;JavaScript automatically provides the &lt;code&gt;resolve()&lt;/code&gt; and &lt;code&gt;reject()&lt;/code&gt; functions when creating a Promise.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;resolve()&lt;/code&gt; changes a Promise to &lt;strong&gt;Fulfilled&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;reject()&lt;/code&gt; changes a Promise to &lt;strong&gt;Rejected&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.then()&lt;/code&gt; handles successful results.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.catch()&lt;/code&gt; handles errors and rejected Promises.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.finally()&lt;/code&gt; executes regardless of success or failure.&lt;/li&gt;
&lt;li&gt;Promise chaining makes complex asynchronous operations easier to manage.&lt;/li&gt;
&lt;li&gt;Errors automatically propagate through the Promise chain until they are handled by the nearest &lt;code&gt;.catch()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;Today's learning helped me understand how JavaScript manages asynchronous operations using Promises.I learned why callback hell occurs, how Promises improve code readability, how Promise states work, how &lt;code&gt;resolve()&lt;/code&gt; and &lt;code&gt;reject()&lt;/code&gt; are provided by JavaScript, and how &lt;code&gt;.then()&lt;/code&gt;, &lt;code&gt;.catch()&lt;/code&gt;, &lt;code&gt;.finally()&lt;/code&gt;, Promise chaining, and error propagation make asynchronous programming much cleaner and easier to maintain.&lt;/p&gt;

&lt;p&gt;Understanding these concepts has also given me a much stronger foundation for learning &lt;strong&gt;&lt;code&gt;async/await&lt;/code&gt;&lt;/strong&gt;, since it is built on top of Promises.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>blog</category>
      <category>learning</category>
    </item>
    <item>
      <title>My JavaScript Learning Journey:Object-Oriented Programming (OOP) in JavaScript</title>
      <dc:creator>HARSHITH GADDAM</dc:creator>
      <pubDate>Mon, 27 Jul 2026 17:08:59 +0000</pubDate>
      <link>https://dev.to/harshith_gaddam/my-javascript-learning-journey4-pillars-of-oops-350</link>
      <guid>https://dev.to/harshith_gaddam/my-javascript-learning-journey4-pillars-of-oops-350</guid>
      <description>&lt;p&gt;JavaScript supports Object-Oriented Programming (OOP) through objects, prototypes, and classes. ES6 introduced a cleaner class syntax, making OOP easier to understand and write. In this blog, I'll explain the four pillars of OOP and some useful class features in JavaScript.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Inheritance
&lt;/h1&gt;

&lt;p&gt;Inheritance allows one class to reuse the properties and methods of another class.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;class Animal {&lt;br&gt;
    eat() {&lt;br&gt;
        console.log("Eating");&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;class Dog extends Animal {}&lt;/p&gt;

&lt;p&gt;const dog = new Dog();&lt;/p&gt;

&lt;p&gt;dog.eat();&lt;/p&gt;

&lt;p&gt;Since &lt;code&gt;Dog&lt;/code&gt; extends &lt;code&gt;Animal&lt;/code&gt;, it inherits the &lt;code&gt;eat()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;This helps us avoid writing the same code again.&lt;/p&gt;


&lt;h1&gt;
  
  
  2. Polymorphism
&lt;/h1&gt;

&lt;p&gt;Polymorphism means &lt;strong&gt;one method can behave differently depending on the object that calls it&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In JavaScript, this is usually achieved by overriding a parent class method in a child class.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;class Animal {&lt;br&gt;
    speak() {&lt;br&gt;
        console.log("Animal makes a sound");&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;class Dog extends Animal {&lt;br&gt;
    speak() {&lt;br&gt;
        console.log("Dog barks");&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;class Cat extends Animal {&lt;br&gt;
    speak() {&lt;br&gt;
        console.log("Cat meows");&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;const dog = new Dog();&lt;br&gt;
const cat = new Cat();&lt;/p&gt;

&lt;p&gt;dog.speak();&lt;br&gt;
cat.speak();&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;Dog barks&lt;br&gt;
Cat meows&lt;/p&gt;

&lt;p&gt;Here, all classes have the same &lt;code&gt;speak()&lt;/code&gt; method, but each class provides its own implementation. This is called &lt;strong&gt;polymorphism&lt;/strong&gt;.&lt;/p&gt;


&lt;h1&gt;
  
  
  3. Abstraction
&lt;/h1&gt;

&lt;p&gt;Abstraction means &lt;strong&gt;showing only the necessary functionality and hiding the internal implementation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, when we start a car, we only press the start button. We don't need to know how the engine, fuel system, and battery work internally.&lt;/p&gt;

&lt;p&gt;JavaScript allows us to achieve abstraction using classes and private methods or private fields.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;class Car {&lt;br&gt;
    start() {&lt;br&gt;
        this.#checkFuel();&lt;br&gt;
        console.log("Car Started");&lt;br&gt;
    }&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#checkFuel() {
    console.log("Checking Fuel...");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;const car = new Car();&lt;/p&gt;

&lt;p&gt;car.start();&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Checking Fuel...
Car Started
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user only calls &lt;code&gt;start()&lt;/code&gt;. The internal method &lt;code&gt;#checkFuel()&lt;/code&gt; remains hidden from outside the class. This makes the code easier to use and protects the internal implementation.&lt;/p&gt;

&lt;h1&gt;
  
  
  4. Static Members
&lt;/h1&gt;

&lt;p&gt;Normally, we create an object before calling a method.&lt;/p&gt;

&lt;p&gt;const obj = new Person();&lt;/p&gt;

&lt;p&gt;But some methods belong to the class itself, not to its objects.&lt;/p&gt;

&lt;p&gt;These are called &lt;strong&gt;static methods&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;class MathUtil {&lt;br&gt;
    static add(a, b) {&lt;br&gt;
        return a + b;&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;console.log(MathUtil.add(5, 3));&lt;/p&gt;

&lt;p&gt;Notice that we didn't create an object.&lt;/p&gt;




&lt;h1&gt;
  
  
  5. Getters and Setters
&lt;/h1&gt;

&lt;p&gt;Getters and setters allow us to control how properties are read and updated.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;class Person {&lt;br&gt;
    constructor(name) {&lt;br&gt;
        this._name = name;&lt;br&gt;
    }&lt;br&gt;
    get name() {&lt;br&gt;
        return this._name;&lt;br&gt;
    }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set name(value) {
    if (value.length &amp;gt;= 3) {
        this._name = value;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;This helps us validate data before updating it.&lt;/p&gt;




&lt;h1&gt;
  
  
  6. Encapsulation Using Closures
&lt;/h1&gt;

&lt;p&gt;Encapsulation means bundling data and methods into a single unit.And Closure means accessing the outer methods variables inside inner methods after outer function(method) has completed its execution.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;function BankAccount() {&lt;br&gt;
    let balance = 1000;&lt;br&gt;
    return {&lt;br&gt;
        deposit(amount) {&lt;br&gt;
            balance += amount;&lt;br&gt;
        },&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    getBalance() {
        return balance;
    }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
const account = BankAccount();&lt;br&gt;
account.deposit(500);&lt;br&gt;
console.log(account.getBalance());&lt;br&gt;
//console.log(account.balance); will throw an error&lt;/p&gt;

&lt;p&gt;The variable &lt;code&gt;balance&lt;/code&gt; cannot be accessed directly from outside the function.&lt;/p&gt;

&lt;p&gt;In the above Example you can see balance,deposit(),getBalance() are bundled together.&lt;/p&gt;




&lt;h1&gt;
  
  
  7. Private Fields (&lt;code&gt;#field&lt;/code&gt;)
&lt;/h1&gt;

&lt;p&gt;Modern JavaScript provides another way to hide data using private fields.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;class BankAccount {&lt;br&gt;
    #balance = 1000;&lt;br&gt;
    deposit(amount) {&lt;br&gt;
        this.#balance += amount;&lt;br&gt;
    }&lt;br&gt;
    getBalance() {&lt;br&gt;
        return this.#balance;&lt;br&gt;
    }&lt;br&gt;
}&lt;br&gt;
const account = new BankAccount();&lt;br&gt;
account.deposit(500);&lt;br&gt;
console.log(account.getBalance());&lt;br&gt;
Trying to access:&lt;br&gt;
account.#balance;&lt;/p&gt;

&lt;p&gt;will cause an error because private fields can only be accessed inside the class.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Now I know that JavaScript's OOP system is built on prototypes, and classes simply make the syntax cleaner and easier to read. Understanding these concepts gives a strong foundation for writing better JavaScript code.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>My JavaScript Learning Journey:Prototypes</title>
      <dc:creator>HARSHITH GADDAM</dc:creator>
      <pubDate>Mon, 27 Jul 2026 12:17:05 +0000</pubDate>
      <link>https://dev.to/harshith_gaddam/my-javascript-learning-journeyprototypes-and-object-oriented-programming-oop-2765</link>
      <guid>https://dev.to/harshith_gaddam/my-javascript-learning-journeyprototypes-and-object-oriented-programming-oop-2765</guid>
      <description>&lt;p&gt;JavaScript is different from many other programming languages when it comes to Object-Oriented Programming (OOP) because it is prototype-based. Instead of using classes as its foundation, JavaScript uses prototypes. &lt;/p&gt;

&lt;p&gt;In this blog, I'll explain the topics I learned today.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. What is a Prototype?
&lt;/h1&gt;

&lt;p&gt;A &lt;strong&gt;prototype&lt;/strong&gt; is a shared object that stores common methods and properties.&lt;/p&gt;

&lt;p&gt;Instead of creating a separate copy of the same method for every object, JavaScript stores it once in the prototype, and all objects created from the same constructor or class share it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;function Person(name) {&lt;br&gt;
    this.name = name;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Person.prototype.greet = function () {&lt;br&gt;
    console.log(&lt;code&gt;Hello, I'm ${this.name}&lt;/code&gt;);&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;const p1 = new Person("Harshith");&lt;br&gt;
const p2 = new Person("Rahul");&lt;/p&gt;

&lt;p&gt;p1.greet();&lt;br&gt;
p2.greet();&lt;/p&gt;

&lt;p&gt;Here, both &lt;code&gt;p1&lt;/code&gt; and &lt;code&gt;p2&lt;/code&gt; use the same &lt;code&gt;greet()&lt;/code&gt; method from &lt;code&gt;Person.prototype&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This saves memory because JavaScript doesn't create multiple copies of the same function.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Prototype vs &lt;code&gt;__proto__&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;This topic confused me at first, but here's the difference.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;prototype&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Exists on &lt;strong&gt;functions&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Used when creating new objects with the &lt;code&gt;new&lt;/code&gt; keyword.&lt;/li&gt;
&lt;li&gt;Stores shared methods.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;function Person(name) {&lt;br&gt;
    this.name = name;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Person.prototype.greet = function () {};&lt;br&gt;
const p1 = new Person("Harshith");&lt;br&gt;
 p1 will have a property called "&lt;strong&gt;proto&lt;/strong&gt;" there it stores the prototype of Person&lt;br&gt;
p1.&lt;strong&gt;proto&lt;/strong&gt;=Person.prototype;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;__proto__&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Exists on &lt;strong&gt;objects&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Points to the object's prototype.&lt;/li&gt;
&lt;li&gt;JavaScript follows this link while searching for properties.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;const person = new Person("Harshith");&lt;/p&gt;

&lt;p&gt;console.log(person.&lt;strong&gt;proto&lt;/strong&gt; === Person.prototype);&lt;/p&gt;

&lt;p&gt;A simple way to remember:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;prototype&lt;/code&gt; belongs to functions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;__proto__&lt;/code&gt; belongs to objects.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  3. Prototype Chain
&lt;/h1&gt;

&lt;p&gt;When JavaScript cannot find a property inside an object, it searches its prototype.&lt;/p&gt;

&lt;p&gt;If it is still not found, it continues searching through the next prototype until it reaches &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;const animal = {&lt;br&gt;
    eat() {&lt;br&gt;
        console.log("Eating");&lt;br&gt;
    }&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;const dog = Object.create(animal);&lt;/p&gt;

&lt;p&gt;dog.eat();&lt;/p&gt;

&lt;p&gt;JavaScript searches like this:&lt;/p&gt;

&lt;p&gt;dog&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;animal.prototype&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;null&lt;/p&gt;

&lt;p&gt;This searching process is called the &lt;strong&gt;Prototype Chain&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  4. Object.create()
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;Object.create()&lt;/code&gt; creates a new object whose prototype is another object.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;const animal = {&lt;br&gt;
    eat() {&lt;br&gt;
        console.log("Eating");&lt;br&gt;
    }&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;const dog = Object.create(animal);&lt;/p&gt;

&lt;p&gt;dog.eat();&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;dog&lt;/code&gt; object doesn't have its own &lt;code&gt;eat()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;It inherits it from &lt;code&gt;animal&lt;/code&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  5. Classes are Syntactic Sugar
&lt;/h1&gt;

&lt;p&gt;Before ES6, constructor functions were used to create objects.&lt;/p&gt;

&lt;p&gt;function Person(name) {&lt;br&gt;
    this.name = name;&lt;br&gt;
}&lt;br&gt;
Person.prototype.greet=function (){&lt;br&gt;
                            console.log(this.name);&lt;br&gt;
                             }&lt;/p&gt;

&lt;p&gt;Now we can write:&lt;/p&gt;

&lt;p&gt;class Person {&lt;br&gt;
    constructor(name) {&lt;br&gt;
        this.name = name;&lt;br&gt;
    }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;greet() {
    console.log(this.name);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Both work almost the same internally.&lt;/p&gt;

&lt;p&gt;A class is simply a cleaner and easier syntax built on top of JavaScript's prototype system.&lt;/p&gt;

&lt;h1&gt;
  
  
  conclusion
&lt;/h1&gt;

&lt;p&gt;At first, JavaScript prototypes can feel confusing because there are terms like &lt;code&gt;prototype&lt;/code&gt;, &lt;code&gt;__proto__&lt;/code&gt;, constructor functions, and classes. But once I understood that objects inherit methods through prototypes, everything started making sense.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>blog</category>
      <category>learning</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>My JavaScript Learning Journey:Understanding the JavaScript Event Loop and Concurrency Model</title>
      <dc:creator>HARSHITH GADDAM</dc:creator>
      <pubDate>Tue, 21 Jul 2026 13:31:11 +0000</pubDate>
      <link>https://dev.to/harshith_gaddam/my-javascript-learning-journeyunderstanding-the-javascript-event-loop-and-concurrency-model-4oec</link>
      <guid>https://dev.to/harshith_gaddam/my-javascript-learning-journeyunderstanding-the-javascript-event-loop-and-concurrency-model-4oec</guid>
      <description>&lt;p&gt;Today, I learned one of the most important concepts in JavaScript: the Event Loop and the Concurrency Model.&lt;/p&gt;

&lt;h1&gt;
  
  
  JavaScript is Single-Threaded
&lt;/h1&gt;

&lt;p&gt;JavaScript is a single-threaded language. This means it can execute only one piece of JavaScript code at a time.&lt;/p&gt;

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

&lt;p&gt;console.log("A");&lt;br&gt;
console.log("B");&lt;br&gt;
console.log("C");&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;A&lt;br&gt;
B&lt;br&gt;
C&lt;/p&gt;

&lt;p&gt;JavaScript executes these statements one after another.&lt;/p&gt;




&lt;h1&gt;
  
  
  What is the Call Stack?
&lt;/h1&gt;

&lt;p&gt;The Call Stack is where JavaScript executes functions. Whenever a function is called, it is added to the stack. After the function finishes executing, it is removed from the stack.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;function one() {&lt;br&gt;
    two();&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;function two() {&lt;br&gt;
    console.log("Hello");&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;one();&lt;/p&gt;

&lt;p&gt;Execution order:&lt;/p&gt;

&lt;p&gt;one()&lt;br&gt;
↓&lt;br&gt;
two()&lt;br&gt;
↓&lt;br&gt;
console.log()&lt;br&gt;
↓&lt;br&gt;
Stack becomes empty&lt;/p&gt;

&lt;p&gt;The Call Stack follows the Last In, First Out (LIFO) principle.&lt;/p&gt;

&lt;h1&gt;
  
  
  What are Web APIs and Node APIs?
&lt;/h1&gt;

&lt;p&gt;Some operations take time, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Waiting for a timer&lt;/li&gt;
&lt;li&gt;Making an API request&lt;/li&gt;
&lt;li&gt;Reading a file&lt;/li&gt;
&lt;li&gt;Listening for button clicks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JavaScript itself cannot perform these operations.&lt;/p&gt;

&lt;p&gt;Instead, it asks the runtime to handle them.&lt;/p&gt;

&lt;h3&gt;
  
  
  In Browsers
&lt;/h3&gt;

&lt;p&gt;The browser provides Web APIs such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;setTimeout()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;setInterval()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fetch()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;addEventListener()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;DOM APIs&lt;/li&gt;
&lt;li&gt;&lt;code&gt;localStorage&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  In Node.js
&lt;/h3&gt;

&lt;p&gt;Node.js provides Node APIs such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;fs.readFile()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fs.writeFile()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;path&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;os&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;http&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These APIs perform asynchronous work outside the JavaScript engine.&lt;/p&gt;




&lt;h1&gt;
  
  
  Callback (Macrotask) Queue
&lt;/h1&gt;

&lt;p&gt;When an asynchronous operation like &lt;code&gt;setTimeout()&lt;/code&gt; finishes, its callback does not execute immediately.&lt;/p&gt;

&lt;p&gt;Instead, it is placed into the Callback Queue, also called the Macrotask Queue.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;setTimeout(() =&amp;gt; {&lt;br&gt;
    console.log("Timer");&lt;br&gt;
}, 1000);&lt;/p&gt;

&lt;p&gt;After one second Call back function added to Callback Queue.&lt;br&gt;
It waits there until the Event Loop moves it to the Call Stack.&lt;/p&gt;

&lt;h1&gt;
  
  
  Microtask Queue
&lt;/h1&gt;

&lt;p&gt;The Microtask Queue has a higher priority than the Callback Queue.&lt;/p&gt;

&lt;p&gt;The following callbacks are added to the Microtask Queue:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Promise.then()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Promise.catch()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Promise.finally()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;await&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;queueMicrotask()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Promise.resolve().then(() =&amp;gt; {&lt;br&gt;
    console.log("Promise");&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;The callback is placed in the Microtask Queue.&lt;/p&gt;

&lt;h1&gt;
  
  
  Event Loop
&lt;/h1&gt;

&lt;p&gt;The Event Loop is responsible for checking whether the Call Stack is empty.&lt;/p&gt;

&lt;p&gt;When the Call Stack becomes empty, it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Executes all Microtasks&lt;/li&gt;
&lt;li&gt;Executes one Callback (Macrotask)&lt;/li&gt;
&lt;li&gt;Again checks call stack is empty or not and does 1&amp;amp;2.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It does not execute code itself. It simply moves callbacks from the queues to the Call Stack.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why do Promises execute before setTimeout()?
&lt;/h1&gt;

&lt;p&gt;Consider this example:&lt;/p&gt;

&lt;p&gt;console.log("Start");&lt;/p&gt;

&lt;p&gt;setTimeout(() =&amp;gt; {&lt;br&gt;
    console.log("Timeout");&lt;br&gt;
}, 0);&lt;/p&gt;

&lt;p&gt;Promise.resolve().then(() =&amp;gt; {&lt;br&gt;
    console.log("Promise");&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;console.log("End");&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
Start&lt;br&gt;
End&lt;br&gt;
Promise&lt;br&gt;
Timeout&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Promise.then()&lt;/code&gt; goes to the &lt;strong&gt;Microtask Queue&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setTimeout()&lt;/code&gt; goes to the &lt;strong&gt;Callback (Macrotask) Queue&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The Event Loop always executes &lt;strong&gt;all Microtasks first&lt;/strong&gt; before executing Macrotasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Does setTimeout() execute exactly on time?
&lt;/h1&gt;

&lt;p&gt;A common misunderstanding is that:&lt;/p&gt;

&lt;p&gt;setTimeout(callback, 1000);&lt;/p&gt;

&lt;p&gt;means the callback will execute exactly after one second.&lt;/p&gt;

&lt;p&gt;This is not true.&lt;/p&gt;

&lt;p&gt;It means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Execute the callback after at least one second.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If the Call Stack is busy with synchronous code, the callback has to wait.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;setTimeout(() =&amp;gt; {&lt;br&gt;
    console.log("Done");&lt;br&gt;
}, 1000);&lt;/p&gt;

&lt;p&gt;// Imagine this loop takes 3 seconds&lt;br&gt;
for (let i = 0; i &amp;lt; 1e10; i++) {}&lt;/p&gt;

&lt;p&gt;console.log("Finished");&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
Finished&lt;br&gt;
Done&lt;/p&gt;

&lt;p&gt;Even though the timer finished after one second, the callback waited until the Call Stack became empty.&lt;/p&gt;




&lt;h1&gt;
  
  
  What is the JavaScript Concurrency Model?
&lt;/h1&gt;

&lt;p&gt;JavaScript can execute only one line of code at a time, but it can still handle many asynchronous operations.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;A timer can be counting.&lt;/li&gt;
&lt;li&gt;A network request can be downloading.&lt;/li&gt;
&lt;li&gt;The browser can listen for button clicks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these operations are handled by the browser or Node.js while JavaScript continues executing other code.&lt;/p&gt;

&lt;p&gt;When these operations finish, their callbacks are added to the appropriate queue.&lt;/p&gt;

&lt;p&gt;This ability to make multiple operations progress during the same period of time is called the Concurrency Model.&lt;/p&gt;

&lt;h1&gt;
  
  
  Cooperative Concurrency vs True Parallelism
&lt;/h1&gt;

&lt;p&gt;These two terms are often confused.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cooperative Concurrency
&lt;/h3&gt;

&lt;p&gt;Only one JavaScript task runs at a time.&lt;/p&gt;

&lt;p&gt;Tasks take turns executing.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;One chef starts cooking rice, then makes tea while the rice cooks.&lt;/p&gt;

&lt;p&gt;The chef is not doing both tasks at the exact same moment, but both tasks are progressing.&lt;/p&gt;

&lt;p&gt;JavaScript works like this.&lt;/p&gt;

&lt;h3&gt;
  
  
  True Parallelism
&lt;/h3&gt;

&lt;p&gt;Multiple tasks execute at the exact same time using different CPU cores or threads.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chef 1 cooks rice.&lt;/li&gt;
&lt;li&gt;Chef 2 makes tea.&lt;/li&gt;
&lt;li&gt;Chef 3 cuts vegetables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three are working simultaneously.&lt;/p&gt;

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

&lt;p&gt;Learning the Event Loop and the Concurrency Model helped me understand how JavaScript performs asynchronous operations without blocking the main thread. These concepts explain why Promise callbacks execute before &lt;code&gt;setTimeout()&lt;/code&gt;, why timers are not always exact, and how browsers and Node.js work together with JavaScript to build responsive applications.&lt;/p&gt;

&lt;p&gt;Understanding these fundamentals is essential for writing efficient JavaScript code.&lt;br&gt;
Thank you for reading! If you're also learning JavaScript, I hope this summary helps you understand these concepts more clearly. Happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>blog</category>
      <category>learning</category>
    </item>
    <item>
      <title>My JavaScript Learning Journey: Understanding How JavaScript Really Works</title>
      <dc:creator>HARSHITH GADDAM</dc:creator>
      <pubDate>Tue, 21 Jul 2026 11:32:29 +0000</pubDate>
      <link>https://dev.to/harshith_gaddam/my-javascript-learning-journey-understanding-how-javascript-really-works-37m8</link>
      <guid>https://dev.to/harshith_gaddam/my-javascript-learning-journey-understanding-how-javascript-really-works-37m8</guid>
      <description>&lt;p&gt;During this learning session, I focused on JavaScript's internal working, including Execution Context, Variables, Scope, Closures, Hoisting, this binding, Call Stack, and Clean Code Principles like DRY and KISS.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;JavaScript Execution Context&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The first topic I learned was Execution Context.&lt;/p&gt;

&lt;p&gt;An Execution Context is the environment in which JavaScript executes code. Whenever JavaScript runs a script or calls a function, it creates an execution context.&lt;/p&gt;

&lt;p&gt;Each execution context has two phases:&lt;/p&gt;

&lt;p&gt;i)Memory Creation Phase&lt;br&gt;
     Before executing the code, JavaScript scans it and allocates memory.&lt;/p&gt;

&lt;p&gt;During this phase:&lt;/p&gt;

&lt;p&gt;var variables are initialized with undefined.&lt;br&gt;
let and const are allocated memory but remain uninitialized (Temporal Dead Zone).&lt;br&gt;
Function declarations are stored completely in memory.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;console.log(a);&lt;br&gt;
var a = 10;&lt;br&gt;
Output:&lt;br&gt;
undefined&lt;/p&gt;

&lt;p&gt;Because var is initialized with undefined during the memory phase.&lt;/p&gt;

&lt;p&gt;ii)Code Execution Phase&lt;/p&gt;

&lt;p&gt;After memory allocation, JavaScript starts executing the code line by line.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
var a = 10;&lt;br&gt;
console.log(a);&lt;br&gt;
Output:&lt;br&gt;
10&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Variables in JavaScript&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I learned the differences between var, let, and const.&lt;/p&gt;

&lt;p&gt;a)var&lt;br&gt;
-Function scoped&lt;br&gt;
-Can be redeclared&lt;br&gt;
-Can be reassigned&lt;br&gt;
-Hoisted with undefined&lt;/p&gt;

&lt;p&gt;b)let&lt;br&gt;
Block scoped&lt;br&gt;
Cannot be redeclared in the same scope&lt;br&gt;
Can be reassigned&lt;br&gt;
Exists in the Temporal Dead Zone before initialization&lt;/p&gt;

&lt;p&gt;c)const&lt;br&gt;
Block scoped&lt;br&gt;
Cannot be redeclared&lt;br&gt;
Cannot be reassigned&lt;br&gt;
Must be initialized during declaration&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Lexical Scope&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One important concept I learned is Lexical Scope.&lt;/p&gt;

&lt;p&gt;Lexical Scope means a function can access variables from the scope where it was created.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;let name = "Harshith";&lt;/p&gt;

&lt;p&gt;function greet() {&lt;br&gt;
    console.log(name);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;greet();&lt;/p&gt;

&lt;p&gt;The function accesses name because it was created inside the same scope.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Closures&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A Closure is created when a function remembers variables from its outer scope even after the outer function has finished executing.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;function counter() {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let count = 0;

return function () {
    count++;
    console.log(count);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;const increment = counter();&lt;/p&gt;

&lt;p&gt;increment();&lt;br&gt;
increment();&lt;br&gt;
increment();&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
1&lt;br&gt;
2&lt;br&gt;
3&lt;/p&gt;

&lt;p&gt;The variable count remains available because of the closure.&lt;/p&gt;

&lt;p&gt;Closures are commonly used to create private variables and implement the module pattern.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hoisting&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hoisting is JavaScript's behavior of moving declarations to the top of their scope before execution.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;console.log(a);&lt;br&gt;
var a = 10;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
undefined&lt;/p&gt;

&lt;p&gt;For let and const:&lt;/p&gt;

&lt;p&gt;console.log(a);&lt;br&gt;
let a = 10;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
ReferenceError&lt;/p&gt;

&lt;p&gt;because the variable is inside the Temporal Dead Zone until it is initialized.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understanding this Binding&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One of the most interesting topics I learned was how JavaScript decides the value of this.&lt;/p&gt;

&lt;p&gt;a)Default Binding&lt;br&gt;
function greet() {&lt;br&gt;
    console.log(this);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;greet();&lt;/p&gt;

&lt;p&gt;In non-strict mode, this refers to the global object.&lt;/p&gt;

&lt;p&gt;b)Implicit Binding&lt;br&gt;
const person = {&lt;br&gt;
    name: "Harshith",&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;greet() {
    console.log(this.name);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;};&lt;/p&gt;

&lt;p&gt;person.greet();&lt;/p&gt;

&lt;p&gt;Here, this refers to person.&lt;/p&gt;

&lt;p&gt;c)Explicit Binding&lt;/p&gt;

&lt;p&gt;JavaScript allows us to manually set this using call(), apply(), and bind().&lt;/p&gt;

&lt;p&gt;function greet(city) {&lt;br&gt;
    console.log(this.name, city);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;const person = {&lt;br&gt;
    name: "Harshith"&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;greet.call(person, "Hyderabad");&lt;/p&gt;

&lt;p&gt;d)new Binding&lt;/p&gt;

&lt;p&gt;When a function is called using the new keyword, JavaScript creates a new object and binds this to it.&lt;/p&gt;

&lt;p&gt;function Person(name) {&lt;br&gt;
    this.name = name;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;const p = new Person("Harsh");&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Writing Better Code with DRY and KISS&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Besides JavaScript internals, I also learned two important software engineering principles.&lt;/p&gt;

&lt;p&gt;a)DRY (Don't Repeat Yourself)&lt;/p&gt;

&lt;p&gt;Instead of repeating the same logic multiple times, create reusable functions.&lt;/p&gt;

&lt;p&gt;This makes code easier to maintain.&lt;/p&gt;

&lt;p&gt;b)KISS (Keep It Simple, Stupid)&lt;/p&gt;

&lt;p&gt;Write simple, readable code instead of overly complex solutions.&lt;/p&gt;

&lt;p&gt;Simple code is easier to understand, debug, and maintain.&lt;/p&gt;

&lt;p&gt;Thank you for reading! If you're also learning JavaScript, I hope this summary helps you understand these core concepts more clearly. Happy coding! &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>blog</category>
    </item>
  </channel>
</rss>
