<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Barun Tiwary]]></title><description><![CDATA[I do write technical blog and about the things which I explore in tech.]]></description><link>https://blog.baruntiwary.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1767994488863/003189b6-50bf-44ea-9f9f-5e6d34a75c95.png</url><title>Barun Tiwary</title><link>https://blog.baruntiwary.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Apr 2026 12:19:30 GMT</lastBuildDate><atom:link href="https://blog.baruntiwary.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[JavaScript Destructuring Explained (In Simple Way 😎)]]></title><description><![CDATA[Alright… today we are going to talk about something that every JavaScript developer uses… but many don’t truly feel it.
Destructuring.
And trust me… once you understand this properly, your code will g]]></description><link>https://blog.baruntiwary.dev/javascript-destructuring-explained-in-simple-way</link><guid isPermaLink="true">https://blog.baruntiwary.dev/javascript-destructuring-explained-in-simple-way</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Sat, 04 Apr 2026 20:46:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/56d3c53e-b545-44a1-8561-19dc073eea9c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Alright… today we are going to talk about something that every JavaScript developer uses… but many don’t truly <em>feel</em> it.</p>
<p><strong>Destructuring.</strong></p>
<p>And trust me… once you understand this properly, your code will go from:</p>
<blockquote>
<p>“Bhai thoda lamba hai…”</p>
</blockquote>
<p>to</p>
<blockquote>
<p>“Arre waah… clean code 😎”</p>
</blockquote>
<p>Also, this is one of those features that makes you look like a <em>pro developer</em> in front of juniors.</p>
<p>So let’s break it down… in our style.</p>
<hr />
<h1>So, what does Destructuring mean?</h1>
<p>Well technically!!!…</p>
<p>Destructuring is a way to unpack values from arrays or objects into separate variables.</p>
<p>Too technical again 😑</p>
<p>Let’s understand in our own way…</p>
<p>👉 <strong>Destructuring means: taking data out of a structure (array/object) and directly putting it into variables.</strong></p>
<p>Simple.</p>
<hr />
<h1>The Problem (Before Destructuring)</h1>
<p>Let’s say you have this object:</p>
<pre><code class="language-js">const user = {
  name: "Barun",
  age: 22,
  city: "Patna"
};
</code></pre>
<p>Now if you want to use these values:</p>
<pre><code class="language-js">const name = user.name;
const age = user.age;
const city = user.city;

console.log(name, age, city);
</code></pre>
<p>Works fine…</p>
<p>But imagine 10 properties…</p>
<p>or nested objects…</p>
<p>or APIs…</p>
<p>👉 You will cry 😭</p>
<hr />
<h1>Enter Destructuring 🚀</h1>
<pre><code class="language-js">const user = {
  name: "Barun",
  age: 22,
  city: "Patna"
};

const { name, age, city } = user;

console.log(name, age, city);
</code></pre>
<p>बस्स्स्स… done.</p>
<p>No repetition. No headache.</p>
<hr />
<h1>Destructuring Arrays</h1>
<p>Let’s start with arrays first.</p>
<pre><code class="language-js">const songs = ["Saiyaara", "Tum Hi Ho", "Kesariya"];
</code></pre>
<h3>Without destructuring:</h3>
<pre><code class="language-js">const first = songs[0];
const second = songs[1];
const third = songs[2];
</code></pre>
<h3>With destructuring:</h3>
<pre><code class="language-js">const [first, second, third] = songs;

console.log(first);  // Saiyaara
console.log(second); // Tum Hi Ho
</code></pre>
<p>👉 See the difference?</p>
<p>No indexing. No confusion.</p>
<hr />
<h2>Real-Life Example 🎧</h2>
<p>Imagine your playlist:</p>
<pre><code class="language-js">const playlist = ["Workout Song", "Focus Song", "Sleep Song"];
</code></pre>
<pre><code class="language-js">const [workout, focus, sleep] = playlist;
</code></pre>
<p>Now your variables make <strong>sense</strong>.</p>
<hr />
<h1>Skipping Values in Arrays</h1>
<pre><code class="language-js">const numbers = [10, 20, 30, 40];

const [first, , third] = numbers;

console.log(first); // 10
console.log(third); // 30
</code></pre>
<p>👉 That empty comma means: “ignore this value”</p>
<hr />
<h1>Destructuring Objects</h1>
<p>Now comes the real power 💥</p>
<pre><code class="language-js">const student = {
  name: "Rahul",
  marks: 90,
  subject: "Maths"
};
</code></pre>
<h3>Without destructuring:</h3>
<pre><code class="language-js">const name = student.name;
const marks = student.marks;
</code></pre>
<h3>With destructuring:</h3>
<pre><code class="language-js">const { name, marks } = student;

console.log(name);  // Rahul
console.log(marks); // 90
</code></pre>
<hr />
<h2>Important Rule ⚠️</h2>
<p>👉 <strong>Variable name must match the key name</strong></p>
<pre><code class="language-js">const { name } = student; // correct
</code></pre>
<p>If you want a different name:</p>
<pre><code class="language-js">const { name: studentName } = student;

console.log(studentName);
</code></pre>
<hr />
<h1>Default Values</h1>
<p>Now comes a lifesaver feature 🙏</p>
<pre><code class="language-js">const user = {
  name: "Barun"
};
</code></pre>
<p>Now if you try:</p>
<pre><code class="language-js">const { name, age } = user;

console.log(age); // undefined
</code></pre>
<p>But with default value:</p>
<pre><code class="language-js">const { name, age = 18 } = user;

console.log(age); // 18
</code></pre>
<p>👉 Useful when API doesn’t send data.</p>
<hr />
<h2>Real-world Scenario 🌍</h2>
<pre><code class="language-js">const apiResponse = {
  username: "coder123"
};

const { username, isAdmin = false } = apiResponse;

console.log(isAdmin); // false
</code></pre>
<p>👉 No crash. Safe code.</p>
<hr />
<h1>Before vs After (The Real Truth)</h1>
<h3>Before 😵</h3>
<pre><code class="language-js">const product = {
  title: "Laptop",
  price: 50000,
  brand: "HP"
};

const title = product.title;
const price = product.price;
const brand = product.brand;
</code></pre>
<h3>After 😎</h3>
<pre><code class="language-js">const { title, price, brand } = product;
</code></pre>
<p>👉 Cleaner 👉 Faster 👉 Less repetitive</p>
<hr />
<h1>Why Destructuring is Powerful?</h1>
<p>Let me tell you like a senior developer would…</p>
<h3>1. Less Repetition</h3>
<p>No more <code>object.property</code> again and again.</p>
<h3>2. Cleaner Code</h3>
<p>Your code looks readable and professional.</p>
<h3>3. Easy to Work with APIs</h3>
<p>Most APIs return objects → destructuring saves time.</p>
<h3>4. Better Naming</h3>
<p>You can rename variables easily.</p>
<h3>5. Default Safety</h3>
<p>No more undefined errors.</p>
<hr />
<h1>One Last Example (Interview Style 💀)</h1>
<pre><code class="language-js">const user = {
  name: "Barun",
  address: {
    city: "Patna"
  }
};

const { address: { city } } = user;

console.log(city); // Patna
</code></pre>
<p>👉 Nested destructuring… next level 🔥</p>
<hr />
<h1>Final Thoughts</h1>
<p>Destructuring is not just a feature…</p>
<p>👉 It’s a habit.</p>
<p>Once you start using it, you won’t go back.</p>
<p>And trust me…</p>
<p>When you stop writing things like:</p>
<pre><code class="language-js">user.name
user.age
user.city
</code></pre>
<p>and start writing:</p>
<pre><code class="language-js">const { name, age, city } = user;
</code></pre>
<p>👉 You officially enter <strong>clean code territory</strong>.</p>
<hr />
<h1>Your Turn (Don’t Run Away 😏)</h1>
<h3>Q1</h3>
<pre><code class="language-js">const marks = [50, 60, 70];
</code></pre>
<p>Destructure and print all values.</p>
<hr />
<h3>Q2</h3>
<pre><code class="language-js">const student = {
  name: "Aman",
  age: 20
};
</code></pre>
<p>Extract <code>name</code> and give default value to <code>city</code>.</p>
<hr />
<h3>Q3</h3>
<p>Fix this:</p>
<pre><code class="language-js">const user = { name: "Barun" };
const { age } = user;
console.log(age);
</code></pre>
<hr />
<p>Try these… and don’t cheat 😄</p>
<hr />
<p>And yes…</p>
<p>If you understood this properly…</p>
<p>👉 You are already ahead of 60% beginners.</p>
<p>बाकी 40% अभी भी <code>user.name</code> लिख रहे हैं 😏</p>
<hr />
<p>Happy Coding 🚀 Keep Learning</p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Destructuring Explained with Real Examples (Beginner Guide)]]></title><description><![CDATA[So, what does Destructuring mean?
Well technically!!!...
MDN says:

Destructuring assignment is a JavaScript expression that makes it possible to unpack values from arrays or properties from objects i]]></description><link>https://blog.baruntiwary.dev/javascript-destructuring-explained-beginner-guide</link><guid isPermaLink="true">https://blog.baruntiwary.dev/javascript-destructuring-explained-beginner-guide</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Wed, 25 Mar 2026 15:54:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/8e2c1356-ba71-40ab-a4f9-ce04cda3ffa6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So, what does <strong>Destructuring</strong> mean?</p>
<p>Well technically!!!...</p>
<p>MDN says:</p>
<blockquote>
<p>Destructuring assignment is a JavaScript expression that makes it possible to unpack values from arrays or properties from objects into distinct variables.</p>
</blockquote>
<p>Hmm… again too technical, right? 😅</p>
<p>So let’s understand it in <strong>our own way</strong>.</p>
<hr />
<h2>In Simple Words…</h2>
<p>Destructuring is like:</p>
<p>👉 Taking things out of a bag 👉 And putting them directly into your pockets</p>
<p>Without destructuring: You open the bag again and again.</p>
<p>With destructuring, you take everything out in one shot.</p>
<hr />
<h2>Why Do We Even Need This?</h2>
<p>Let’s take a real-life example.</p>
<p>You ordered a <strong>Swiggy combo meal</strong> 🍔🍟🥤</p>
<p>Without destructuring:</p>
<pre><code class="language-js">const order = {
  burger: "Zinger Burger",
  fries: "Medium Fries",
  drink: "Coke"
};

const burger = order.burger;
const fries = order.fries;
const drink = order.drink;
</code></pre>
<p>Aree bhai… same object… again and again… 🤦‍♂️</p>
<p>Feels like calling your mom every 2 minutes:</p>
<p>“Maa where is burger?” “Maa where is fries?” “Maa where is drink?”</p>
<hr />
<h2>With Destructuring 😎</h2>
<pre><code class="language-js">const order = {
  burger: "Zinger Burger",
  fries: "Medium Fries",
  drink: "Coke"
};

const { burger, fries, drink } = order;

console.log(burger, fries, drink);
</code></pre>
<p>बस… एक लाइन में सब निकाल लिया।</p>
<p>This is destructuring.</p>
<hr />
<h2>Destructuring Objects</h2>
<p>Objects = key-value pairs</p>
<p>Let’s take a small clean example.</p>
<pre><code class="language-js">const student = {
  name: "Barun",
  age: 21,
  course: "BCA"
};
</code></pre>
<h3>Without destructuring</h3>
<pre><code class="language-js">const name = student.name;
const age = student.age;
const course = student.course;
</code></pre>
<h3>With destructuring</h3>
<pre><code class="language-js">const { name, age, course } = student;
</code></pre>
<p>Same result… less headache 😌</p>
<hr />
<h2>Small Visualization (Object → Variables)</h2>
<p>Think like this:</p>
<pre><code class="language-plaintext">student object
   ↓
{name, age, course}
   ↓
name = "Barun"
age = 21
course = "BCA"
</code></pre>
<p>Direct extraction.</p>
<hr />
<h2>Destructuring Arrays</h2>
<p>Arrays are like your music playlist 🎧 (haan haan same example 😏)</p>
<pre><code class="language-js">const songs = ["Kesariya", "Tum Hi Ho", "Believer"];
</code></pre>
<h3>Without destructuring</h3>
<pre><code class="language-js">const firstSong = songs[0];
const secondSong = songs[1];
</code></pre>
<h3>With destructuring</h3>
<pre><code class="language-js">const [firstSong, secondSong] = songs;
</code></pre>
<hr />
<h2>Array Mapping Visualization</h2>
<pre><code class="language-plaintext">["Kesariya", "Tum Hi Ho", "Believer"]

   ↓       ↓
first   second
</code></pre>
<p>Index-based extraction.</p>
<hr />
<h2>Skipping Values</h2>
<pre><code class="language-js">const [first, , third] = songs;

console.log(first); // Kesariya
console.log(third); // Believer
</code></pre>
<p>Second song ignored… just like your gym plan 💀</p>
<hr />
<h2>Default Values</h2>
<p>Now real life problem 👇</p>
<p>What if value is missing?</p>
<pre><code class="language-js">const user = {
  name: "Barun"
};
</code></pre>
<h3>Without default</h3>
<pre><code class="language-js">const age = user.age;
console.log(age); // undefined
</code></pre>
<p>Now your code is crying 😭</p>
<hr />
<h3>With a default value</h3>
<pre><code class="language-js">const { name, age = 18 } = user;

console.log(age); // 18
</code></pre>
<p>Boom 💥</p>
<p>Fallback mil gaya.</p>
<hr />
<h2>Real World Example</h2>
<p>Imagine API response:</p>
<pre><code class="language-js">const response = {
  username: "barun_dev"
};
</code></pre>
<pre><code class="language-js">const { username, isLoggedIn = false } = response;
</code></pre>
<p>Now even if backend forgot 😅 Frontend safe hai.</p>
<h2>Before vs After (Most Important Part)</h2>
<h3>Without Destructuring (Repetitive Code)</h3>
<pre><code class="language-js">const user = {
  name: "Barun",
  age: 21,
  city: "Patna"
};

console.log(user.name);
console.log(user.age);
console.log(user.city);
</code></pre>
<hr />
<h3>With Destructuring</h3>
<pre><code class="language-js">const { name, age, city } = user;

console.log(name);
console.log(age);
console.log(city);
</code></pre>
<hr />
<h2>Another Real Scenario (Function)</h2>
<h3>Without destructuring</h3>
<pre><code class="language-js">function printUser(user) {
  console.log(user.name);
  console.log(user.age);
}
</code></pre>
<h3>With destructuring</h3>
<pre><code class="language-js">function printUser({ name, age }) {
  console.log(name);
  console.log(age);
}
</code></pre>
<hr />
<h2>Benefits of Destructuring</h2>
<p>Let’s not behave like a theory teacher… but still 😏</p>
<h3>1. Less repetitive code</h3>
<p>No more <code>user.user.user.user...</code></p>
<h3>2. Cleaner &amp; readable</h3>
<p>Code looks like a premium version 💎</p>
<h3>3. Faster writing</h3>
<p>Developer happy → productivity high</p>
<h3>4. Easy handling of API data</h3>
<p>Frontend devs ka best friend</p>
<h3>5. Default values = safer code</h3>
<p>No undefined drama</p>
<hr />
<h2>One Small Brain Twist</h2>
<pre><code class="language-js">const user = {
  name: "Barun",
  age: 21
};

const { name: username } = user;

console.log(username);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">Barun
</code></pre>
<p>👉 Renaming also possible 😏</p>
<hr />
<h2>Final Thought</h2>
<p>Destructuring is not just a feature…</p>
<p>It’s like:</p>
<p>👉 Upgrading from keypad phone to smartphone 👉 Same work… but smoother, faster, smarter</p>
<hr />
<h3>Homework (Yes, you can’t escape 😏)</h3>
<p>Create this object:</p>
<pre><code class="language-js">const laptop = {
  brand: "Dell",
  price: 50000,
  ram: "16GB"
};
</code></pre>
<h3>Tasks:</h3>
<ol>
<li><p>Extract all values using destructuring</p>
</li>
<li><p>Add default value for <code>storage</code> (256GB)</p>
</li>
<li><p>Rename <code>brand</code> → <code>company</code> while destructuring</p>
</li>
<li><p>Print everything</p>
</li>
</ol>
<hr />
<p>If you can solve this…</p>
<p>Then congratulations 🎉 You are officially <strong>not scared of destructuring anymore</strong></p>
<hr />
<p>And remember…</p>
<blockquote>
<p>Good developers write code Smart developers write clean code</p>
</blockquote>
<p>Destructuring = Step towards smartness 😎</p>
<hr />
<p>Inspired by Barun style learning with real-life madness 🚀</p>
]]></content:encoded></item><item><title><![CDATA[The Truth About new in JavaScript (Stop Memorizing, Start Understanding)]]></title><description><![CDATA[Alright… today we are going to talk about something which most beginners memorise… but never actually understand.
And that is 👉 the new keyword in JavaScript
You might have seen code like this:
funct]]></description><link>https://blog.baruntiwary.dev/the-truth-about-new-keyword-in-javascript</link><guid isPermaLink="true">https://blog.baruntiwary.dev/the-truth-about-new-keyword-in-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[javascript framework]]></category><category><![CDATA[new keyword]]></category><category><![CDATA[JavaScript interview question]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Mon, 23 Mar 2026 20:05:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/adbc1ad9-47b3-4e19-a9dc-4e84f04d3b2a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Alright… today we are going to talk about something which most beginners <strong>memorise… but never actually understand</strong>.</p>
<p>And that is 👉 <strong>the</strong> <code>new</code> <strong>keyword in JavaScript</strong></p>
<p>You might have seen code like this:</p>
<pre><code class="language-js">function User(name) {
  this.name = name;
}

const user1 = new User("Barun");
</code></pre>
<p>And someone told you:</p>
<blockquote>
<p>"Use <code>new</code> to create objects"</p>
</blockquote>
<p>Bas… khatam… story over.</p>
<p>But <strong>how does it actually work?</strong> Aree bhai… JavaScript koi magic show thodi hai 😄</p>
<p>Let’s break this properly.</p>
<hr />
<h1>So what does <code>new</code> actually do?</h1>
<p>Technically (MDN type definition incoming 😅):</p>
<blockquote>
<p>The <code>new</code> keyword creates an instance of an object from a constructor function.</p>
</blockquote>
<p>Again… too technical.</p>
<hr />
<h2>In Simple Words</h2>
<p>👉 <code>new</code> is like a <strong>factory machine</strong></p>
<p>You give it a constructor… It gives you a ready-made object.</p>
<p>Just like:</p>
<ul>
<li><p>You go to Domino’s</p>
</li>
<li><p>You order pizza</p>
</li>
<li><p>You don’t build it… they build it</p>
</li>
</ul>
<p>Same thing here.</p>
<hr />
<h1>Step by Step: What happens behind the scenes?</h1>
<p>Whenever you write:</p>
<pre><code class="language-js">const user1 = new User("Barun");
</code></pre>
<p>JavaScript secretly does 4 steps.</p>
<p>And THIS is where real understanding starts.</p>
<hr />
<h2>Step 1: Empty object is created</h2>
<pre><code class="language-js">const obj = {};
</code></pre>
<p>JavaScript creates a blank object.</p>
<hr />
<h2>Step 2: <code>this</code> points to that object</h2>
<p>Inside constructor:</p>
<pre><code class="language-js">function User(name) {
  this.name = name;
}
</code></pre>
<p>👉 <code>this</code> now refers to that empty object</p>
<p>So internally:</p>
<pre><code class="language-js">obj.name = "Barun";
</code></pre>
<hr />
<h2>Step 3: Prototype is linked</h2>
<p>This is where most people cry 😭</p>
<pre><code class="language-js">obj.__proto__ = User.prototype;
</code></pre>
<p>Don’t worry… we will understand this slowly.</p>
<hr />
<h2>Step 4: Object is returned</h2>
<pre><code class="language-js">return obj;
</code></pre>
<p>And finally:</p>
<pre><code class="language-js">const user1 = obj;
</code></pre>
<hr />
<h1>Final Visual Flow (IMPORTANT)</h1>
<p>Constructor → Object Creation → Return</p>
<pre><code class="language-plaintext">User("Barun")
     ↓
[ empty object ]
     ↓
this → object
     ↓
prototype linked
     ↓
return object
</code></pre>
<hr />
<h1>Let’s build a real example</h1>
<p>Because theory se zyada <strong>real life samajh aata hai</strong></p>
<hr />
<h2>Example: Student System</h2>
<pre><code class="language-js">function Student(name, marks) {
  this.name = name;
  this.marks = marks;

  this.print = function () {
    console.log(`\({this.name} scored \){this.marks}`);
  };
}

const s1 = new Student("Ravi", 80);
const s2 = new Student("Ankit", 60);

s1.print();
s2.print();
</code></pre>
<hr />
<h2>Real life understanding</h2>
<p>Think like this:</p>
<ul>
<li><p>Constructor = <strong>Blueprint</strong></p>
</li>
<li><p><code>new</code> = <strong>Machine</strong></p>
</li>
<li><p>Object = <strong>Final product</strong></p>
</li>
</ul>
<p>Like:</p>
<ul>
<li><p>Blueprint → "Make a chair"</p>
</li>
<li><p>Machine → Factory</p>
</li>
<li><p>Output → Chair</p>
</li>
</ul>
<hr />
<h1>But wait… what is a Constructor?</h1>
<p>Aree haan… yeh toh define hi nahi kiya 😅</p>
<hr />
<h2>Constructor Function</h2>
<p>👉 A normal function… 👉 But used to create objects</p>
<p>Convention:</p>
<ul>
<li>First letter capital (not mandatory but important)</li>
</ul>
<pre><code class="language-js">function Car(brand, price) {
  this.brand = brand;
  this.price = price;
}
</code></pre>
<hr />
<h2>Creating objects</h2>
<pre><code class="language-js">const car1 = new Car("BMW", 5000000);
const car2 = new Car("Audi", 4000000);
</code></pre>
<p>Now tell me…</p>
<p>Did we manually create objects?</p>
<p>NO ❌</p>
<p><code>new</code> did everything for us.</p>
<hr />
<h1>Now comes the REAL hero: Prototype</h1>
<p>Most people skip this… and regret later.</p>
<hr />
<h2>Why prototypes?</h2>
<p>Look at this:</p>
<pre><code class="language-js">function Student(name) {
  this.name = name;

  this.sayHi = function () {
    console.log("Hello");
  };
}
</code></pre>
<p>If you create 100 students…</p>
<p>👉 100 copies of <code>sayHi</code> will be created 😵</p>
<p>Memory waste.</p>
<hr />
<h2>Solution: Prototype</h2>
<pre><code class="language-js">function Student(name) {
  this.name = name;
}

Student.prototype.sayHi = function () {
  console.log("Hello");
};
</code></pre>
<p>Now:</p>
<ul>
<li><p>Only ONE copy of <code>sayHi</code></p>
</li>
<li><p>All objects share it</p>
</li>
</ul>
<hr />
<h2>How linking works?</h2>
<p>When you do:</p>
<pre><code class="language-js">const s1 = new Student("Barun");
</code></pre>
<p>Behind the scenes:</p>
<pre><code class="language-js">s1.__proto__ === Student.prototype // true
</code></pre>
<hr />
<h1>Visual Understanding of Prototype Linking</h1>
<pre><code class="language-plaintext">Student Constructor
        ↓
Student.prototype  ---&gt; sayHi()
        ↑
        |
      s1 object
</code></pre>
<p>👉 If <code>s1</code> doesn’t find something… 👉 It looks into prototype</p>
<p>Like:</p>
<blockquote>
<p>"Mere paas nahi hai… prototype bhai se puchta hu"</p>
</blockquote>
<hr />
<h1>Important Observation (VERY IMPORTANT)</h1>
<pre><code class="language-js">console.log(s1.sayHi());
</code></pre>
<p>Even though:</p>
<p>❌ <code>sayHi</code> is not inside <code>s1</code> ✅ Still works</p>
<p>Because of prototype chain.</p>
<hr />
<h1>Constructor vs Instance (Clear this once and for all)</h1>
<table>
<thead>
<tr>
<th>Concept</th>
<th>Meaning</th>
</tr>
</thead>
<tbody><tr>
<td>Constructor</td>
<td>Blueprint</td>
</tr>
<tr>
<td>Instance</td>
<td>Actual object</td>
</tr>
</tbody></table>
<p>Example:</p>
<pre><code class="language-js">function User(name) {
  this.name = name;
}

const u1 = new User("Barun");
</code></pre>
<ul>
<li><p><code>User</code> → constructor</p>
</li>
<li><p><code>u1</code> → instance</p>
</li>
</ul>
<hr />
<h1>Common Beginner Mistake 😭</h1>
<pre><code class="language-js">const user = User("Barun"); // ❌ forgot new
</code></pre>
<p>What happens?</p>
<p>👉 <code>this</code> becomes <code>window</code> (or undefined in strict mode)</p>
<p>👉 Bugs start</p>
<hr />
<h2>Always remember</h2>
<p>👉 If constructor → ALWAYS use <code>new</code></p>
<hr />
<h1>Mental Model (Golden Rule)</h1>
<p>Whenever you see <code>new</code> think:</p>
<p>👉 "Object ban raha hai internally"</p>
<p>Not:</p>
<p>👉 "Function call ho raha hai"</p>
<hr />
<h1>Quick Recap</h1>
<ul>
<li><p><code>new</code> creates object</p>
</li>
<li><p>Sets <code>this</code></p>
</li>
<li><p>Links prototype</p>
</li>
<li><p>Returns object</p>
</li>
</ul>
<hr />
<h1>Homework (haan bhai… bhagna mat 😏)</h1>
<h3>Q1: Create a constructor <code>Book</code></h3>
<ul>
<li><p>title</p>
</li>
<li><p>author</p>
</li>
</ul>
<p>Add a method:</p>
<pre><code class="language-js">printDetails()
</code></pre>
<hr />
<h3>Q2: Move method to prototype</h3>
<hr />
<h3>Q3: Check</h3>
<pre><code class="language-js">book1.__proto__ === Book.prototype
</code></pre>
<hr />
<h1>Final Thought</h1>
<p>Most people:</p>
<p>👉 Learn <code>new</code> in 5 minutes 👉 Struggle with it for 2 years</p>
<p>Because they never understood <strong>what happens behind the scenes</strong></p>
<p>Now you know:</p>
<p>👉 JavaScript is not magic 👉 It’s just hidden steps</p>
<hr />
<p>Agar yeh samajh gaya…</p>
<p>👉 Classes (ES6) will feel like <strong>child’s play</strong></p>
<p>And trust me…</p>
<p>👉 80% devs skip this depth</p>
<p>Don’t be that dev. 🚀</p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Callback Functions Explained Simply (With Real Examples & Callback Hell)]]></title><description><![CDATA[So… what exactly is a callback function?
Well technically!!!…
A callback is a function passed as an argument to another function and executed later.
Hmm… sounds like MDN uncle again entered the chat �]]></description><link>https://blog.baruntiwary.dev/javascript-callback-functions-explained-callback-hell-guide</link><guid isPermaLink="true">https://blog.baruntiwary.dev/javascript-callback-functions-explained-callback-hell-guide</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[callback]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Mon, 23 Mar 2026 09:14:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/33a13efb-05ff-42fb-bd79-55694a743b3e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So… what exactly is a <strong>callback function</strong>?</p>
<p>Well technically!!!…</p>
<p>A callback is a function passed as an argument to another function and executed later.</p>
<p>Hmm… sounds like MDN uncle again entered the chat 😅</p>
<p>Let’s understand this in our own way.</p>
<hr />
<h2>Functions as Values (Yes, Functions are VIPs 👑)</h2>
<p>In JavaScript, functions are not just… functions.</p>
<p>They are <strong>values</strong>.</p>
<p>Just like numbers, strings… even like your favourite song.</p>
<pre><code class="language-js">function sayHello() {
  console.log("Hello Bhai");
}

const greet = sayHello;

greet(); // Hello Bhai
</code></pre>
<p>See what happened?</p>
<p>We didn’t call <code>sayHello</code>, we <strong>stored it</strong>.</p>
<p>That means:</p>
<p>👉 Function = Value 👉 Value = Can be passed around</p>
<p>Now things start getting interesting…</p>
<hr />
<h2>Passing Function as Argument (Entry of Callback 🚪)</h2>
<p>Let’s say your mom tells you:</p>
<blockquote>
<p>"Go to the market… and after that call me"</p>
</blockquote>
<p>Here “call me” is something you do <strong>after work is done</strong>.</p>
<p>That is exactly what callback is.</p>
<pre><code class="language-js">function doTask(taskName, callback) {
  console.log(`Doing task: ${taskName}`);
  callback();
}

function taskFinished() {
  console.log("Task completed. Reporting back 😎");
}

doTask("Buy Vegetables", taskFinished);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">Doing task: Buy Vegetables
Task completed. Reporting back 😎
</code></pre>
<p>So here:</p>
<p>👉 <code>taskFinished</code> is a callback 👉 It is passed into <code>doTask</code> 👉 It is executed later</p>
<hr />
<h2>Visual Flow (How Callback Works 🧠)</h2>
<p>Think like this:</p>
<pre><code class="language-plaintext">doTask()
   ↓
Work happens
   ↓
Callback gets called
</code></pre>
<p>Simple life. No tension.</p>
<hr />
<h2>Now Real Problem Begins… Asynchronous World 🌍</h2>
<p>Till now everything was simple.</p>
<p>But JavaScript is not simple…</p>
<p>It loves drama.</p>
<hr />
<h3>Example: Ordering Food 🍔</h3>
<pre><code class="language-js">function orderFood(callback) {
  console.log("Order placed...");

  setTimeout(() =&gt; {
    console.log("Food delivered 🍕");
    callback();
  }, 2000);
}

function eatFood() {
  console.log("Eating food... happiness restored 😌");
}

orderFood(eatFood);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">Order placed...
(wait 2 seconds)
Food delivered 🍕
Eating food... happiness restored 😌
</code></pre>
<p>Why callback here?</p>
<p>Because:</p>
<p>👉 Food delivery takes time 👉 We don’t want to block everything 👉 So we say: “When done… call this function”</p>
<p>This is <strong>asynchronous programming</strong>.</p>
<hr />
<h2>Why Callbacks Are Used?</h2>
<p>Let’s make it crystal clear:</p>
<h3>1. Handle delayed operations</h3>
<p>Like:</p>
<ul>
<li><p>API calls</p>
</li>
<li><p>File reading</p>
</li>
<li><p>Database queries</p>
</li>
</ul>
<h3>2. Avoid blocking code</h3>
<p>JavaScript is single-threaded.</p>
<p>If one thing blocks → everything blocks.</p>
<p>Callbacks help avoid that mess.</p>
<hr />
<h2>Common Real-Life Callback Scenarios</h2>
<h3>1. Button Click (Frontend)</h3>
<pre><code class="language-js">button.addEventListener("click", function () {
  console.log("Button clicked!");
});
</code></pre>
<p>👉 User clicks → callback runs</p>
<hr />
<h3>2. API Call</h3>
<pre><code class="language-js">fetchData(function (data) {
  console.log("Data received:", data);
});
</code></pre>
<p>👉 When data comes → callback runs</p>
<hr />
<h3>3. Timer</h3>
<pre><code class="language-js">setTimeout(() =&gt; {
  console.log("Executed after 2 seconds");
}, 2000);
</code></pre>
<p>👉 Time finishes → callback runs</p>
<hr />
<h2>Now Comes The Villain 😈</h2>
<h2>Callback Hell (Nested Callbacks)</h2>
<p>Everything was fine…</p>
<p>Until this happened:</p>
<pre><code class="language-js">loginUser(function () {
  getUserData(function () {
    getPosts(function () {
      displayPosts(function () {
        console.log("All done 😵");
      });
    });
  });
});
</code></pre>
<p>Look at this 😭</p>
<p>This is called:</p>
<p>👉 Callback Hell 👉 Pyramid of Doom 👉 “Why did I choose programming?” moment</p>
<hr />
<h2>Visual Representation of Callback Hell</h2>
<pre><code class="language-plaintext">loginUser
   ↓
 getUserData
   ↓
  getPosts
     ↓
   displayPosts
       ↓
     Done 😵
</code></pre>
<p>Indentation increasing = Happiness decreasing</p>
<hr />
<h2>What’s the Problem Here?</h2>
<ol>
<li><p>Hard to read</p>
</li>
<li><p>Hard to debug</p>
</li>
<li><p>Hard to maintain</p>
</li>
<li><p>One error → everything breaks</p>
</li>
</ol>
<p>Basically:</p>
<p>👉 Code becomes spaghetti 🍝</p>
<hr />
<h2>Conceptual Understanding (Important ⚠️)</h2>
<p>Callbacks are not bad.</p>
<p>Overusing nested callbacks is bad.</p>
<p>Just like:</p>
<ul>
<li><p>Sugar is fine</p>
</li>
<li><p>Too much sugar → diabetes 😅</p>
</li>
</ul>
<hr />
<h2>So What’s The Solution?</h2>
<p>Modern JavaScript said:</p>
<p>“Enough is enough…”</p>
<p>And gave us:</p>
<p>👉 Promises 👉 Async/Await</p>
<p>(But that’s another blog… patience rakho 😏)</p>
<hr />
<h2>Final Summary (Revision Time 📚)</h2>
<ul>
<li><p>Function can be treated as value</p>
</li>
<li><p>Function can be passed as argument</p>
</li>
<li><p>That passed function = Callback</p>
</li>
<li><p>Callbacks are used in async operations</p>
</li>
<li><p>Too many nested callbacks = Callback Hell</p>
</li>
</ul>
<hr />
<h2>Real Talk Ending 😌</h2>
<p>Callbacks are like instructions you leave for future.</p>
<p>“Bhai… jab kaam ho jaye… mujhe bata dena”</p>
<p>Simple.</p>
<p>But if you keep stacking instructions inside instructions inside instructions…</p>
<p>Even your brain will say:</p>
<blockquote>
<p>“Main nahi kar raha… tu khud dekh le” 😭</p>
</blockquote>
<hr />
<h2>Homework… Because I Care 😏</h2>
<p>Try this:</p>
<ol>
<li><p>Create a function <code>downloadFile(callback)</code></p>
</li>
<li><p>Simulate delay using <code>setTimeout</code></p>
</li>
<li><p>After download → call callback</p>
</li>
<li><p>Inside callback → print "File Ready"</p>
</li>
</ol>
<p>Bonus:</p>
<p>Try creating <strong>nested callbacks</strong> and see where life starts hurting.</p>
<hr />
<p>And yes…</p>
<p>If you understood this…</p>
<p>You are officially one step closer to escaping callback hell 😎</p>
]]></content:encoded></item><item><title><![CDATA[Template literal in JS.]]></title><description><![CDATA[So… let me ask you something…
Have you ever written something like this in JavaScript?
const name = "Barun";
const age = 22;

const message = "My name is " + name + " and I am " + age + " years old.";]]></description><link>https://blog.baruntiwary.dev/template-literals-javascript-vs-string-concatenation-guide</link><guid isPermaLink="true">https://blog.baruntiwary.dev/template-literals-javascript-vs-string-concatenation-guide</guid><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Mon, 23 Mar 2026 08:51:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/91ae72c1-e870-46d3-b488-240061c7b770.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So… let me ask you something…</p>
<p>Have you ever written something like this in JavaScript?</p>
<pre><code class="language-js">const name = "Barun";
const age = 22;

const message = "My name is " + name + " and I am " + age + " years old.";
console.log(message);
</code></pre>
<p>And then after writing this… you just stared at the screen and thought…</p>
<p><strong>“Yeh kya likh diya maine 😐”</strong></p>
<hr />
<h2>The Problem with Traditional String Concatenation</h2>
<p>Technically… what we are doing above is called <strong>string concatenation</strong>.</p>
<p>But practically… we are creating a mess.</p>
<p>Let’s see why.</p>
<h3>Problem 1: Readability goes on leave 🏖️</h3>
<pre><code class="language-js">const order = "User " + username + " has ordered " + itemCount + " items worth ₹" + totalAmount;
</code></pre>
<p>Now tell me honestly…</p>
<p>Can you read this in one go?</p>
<p>Or do you need chai + 2 min silence?</p>
<hr />
<h3>Problem 2: Too many <code>+</code> signs</h3>
<p>Feels like maths class again.</p>
<pre><code class="language-js">"Hello " + name + ", welcome to " + company + ". Your ID is " + id
</code></pre>
<p>After a point, you don’t know what’s string… what’s variable… what’s life…</p>
<hr />
<h3>Problem 3: Multi-line strings = headache</h3>
<pre><code class="language-js">const message = "Hello " + name + "\n" +
                "Welcome to our platform.\n" +
                "We hope you enjoy your stay.";
</code></pre>
<p>This is not coding.</p>
<p>This is suffering.</p>
<hr />
<h2>Enter Template Literals (The Hero 🦸)</h2>
<p>Now JavaScript said…</p>
<p>“Developers are already crying… let me help them.”</p>
<p>And introduced <strong>Template Literals</strong>.</p>
<hr />
<h2>Template Literal Syntax</h2>
<p>Instead of double quotes <code>" "</code> or single quotes <code>' '</code></p>
<p>We use <strong>backticks</strong>:</p>
<pre><code class="language-plaintext">` `
</code></pre>
<p>Yes… that button you never used on your keyboard 😏</p>
<hr />
<h2>Embedding Variables (The Magic ✨)</h2>
<p>Instead of <code>+</code>, we use:</p>
<pre><code class="language-plaintext">${variable}
</code></pre>
<p>Let’s rewrite the same example:</p>
<pre><code class="language-js">const name = "Barun";
const age = 22;

const message = `My name is \({name} and I am \){age} years old.`;
console.log(message);
</code></pre>
<p>Now read this once…</p>
<p>Feels like English sentence, right?</p>
<p>No confusion.</p>
<p>No headache.</p>
<p>No “+ + + + +”.</p>
<hr />
<h2>Before vs After (Reality Check)</h2>
<h3>Old Way 😵</h3>
<pre><code class="language-js">const message = "Hello " + name + ", your order of " + item + " is confirmed.";
</code></pre>
<h3>New Way 😎</h3>
<pre><code class="language-js">const message = `Hello \({name}, your order of \){item} is confirmed.`;
</code></pre>
<p>Difference dekha?</p>
<p>Old code = Puzzle New code = Sentence</p>
<hr />
<h2>Multi-line Strings (Finally Peace 🧘)</h2>
<p>Earlier:</p>
<pre><code class="language-js">const email = "Hi " + name + ",\n" +
              "Your account has been created.\n" +
              "Thank you!";
</code></pre>
<p>Now:</p>
<pre><code class="language-js">const email = `Hi ${name},
Your account has been created.
Thank you!`;
</code></pre>
<p>No <code>\n</code></p>
<p>No <code>+</code></p>
<p>Bas seedha kaam.</p>
<hr />
<h2>Real World Example (Zindagi se juda hua 😄)</h2>
<p>Imagine you are building an e-commerce app.</p>
<pre><code class="language-js">const user = "Ravi";
const product = "iPhone 15";
const price = 80000;

const message = `Hello ${user},
Your order for ${product} has been placed successfully.
Total Amount: ₹${price}`;

console.log(message);
</code></pre>
<p>Now this looks like a real message.</p>
<p>Not like some broken code experiment.</p>
<hr />
<h2>String Interpolation Visualization (Dimag mein picture banao 🧠)</h2>
<p>Think like this:</p>
<pre><code class="language-plaintext">Template Literal = Sentence + Placeholders

"Hello ${name}" → Hello Barun
</code></pre>
<p><code>${}</code> acts like a <strong>slot machine</strong></p>
<p>You put variable → it gives value</p>
<hr />
<h2>Use Cases in Modern JavaScript</h2>
<p>Where do we actually use this?</p>
<p>Everywhere.</p>
<h3>1. Logging</h3>
<pre><code class="language-js">console.log(`User \({username} logged in at \){time}`);
</code></pre>
<h3>2. HTML Templates (Frontend devs ka favourite)</h3>
<pre><code class="language-js">const card = `
  &lt;div&gt;
    &lt;h2&gt;${title}&lt;/h2&gt;
    &lt;p&gt;${description}&lt;/p&gt;
  &lt;/div&gt;
`;
</code></pre>
<h3>3. API Responses</h3>
<pre><code class="language-js">const error = `User with ID ${id} not found`;
</code></pre>
<h3>4. Dynamic Messages</h3>
<pre><code class="language-js">const status = `You have ${notifications} new notifications`;
</code></pre>
<hr />
<h2>One Hidden Superpower 🔥</h2>
<p>You can even run expressions inside <code>${}</code></p>
<pre><code class="language-js">const a = 10;
const b = 20;

console.log(`Sum is ${a + b}`);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">Sum is 30
</code></pre>
<p>Matlab… yeh sirf variable nahi… logic bhi samajhta hai.</p>
<hr />
<h2>Final Suggestion (Golden Rule 🏆)</h2>
<p>Whenever you see yourself writing:</p>
<pre><code class="language-js">"Hello " + name + " something " + value
</code></pre>
<p>Stop right there.</p>
<p>Take a deep breath.</p>
<p>And convert it to:</p>
<pre><code class="language-js">`Hello \({name} something \){value}`
</code></pre>
<hr />
<h2>Conclusion</h2>
<p>So what did we learn today?</p>
<ul>
<li><p>String concatenation works… but makes code ugly</p>
</li>
<li><p>Template literals make code readable and clean</p>
</li>
<li><p><code>${}</code> is your new best friend</p>
</li>
<li><p>Multi-line strings become effortless</p>
</li>
</ul>
<hr />
<h2>Homework (Haan bhai… bhagna mat 😏)</h2>
<p>Create a message like:</p>
<pre><code class="language-plaintext">Hello Aman,
You have 5 pending tasks.
Your total score is 87.
</code></pre>
<p>Using:</p>
<ul>
<li><p>Old concatenation</p>
</li>
<li><p>Template literals</p>
</li>
</ul>
<p>Then compare both.</p>
<p>And tell me honestly…</p>
<p>Which one feels like coding… and which one feels like torture?</p>
<hr />
<p>And remember…</p>
<p>Good developers don’t just write code… They write <strong>readable code</strong>.</p>
<p>See you in next blog 🚀</p>
]]></content:encoded></item><item><title><![CDATA[Error Handling in Javascript: Try, Catch, Finally]]></title><description><![CDATA[So, what do you mean by Errors in JavaScript?
Well technically!!!...
Errors are issues that occur when your JavaScript code stops executing as expected.
But wait…
This sounds like your maths teacher e]]></description><link>https://blog.baruntiwary.dev/error-handling-in-javascript-try-catch-finally</link><guid isPermaLink="true">https://blog.baruntiwary.dev/error-handling-in-javascript-try-catch-finally</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[error handling]]></category><category><![CDATA[trycatch]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Mon, 23 Mar 2026 08:39:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/82f9217c-528e-4ff1-b7d6-63b1255cae61.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So, what do you mean by <strong>Errors in JavaScript</strong>?</p>
<p>Well technically!!!...</p>
<p>Errors are issues that occur when your JavaScript code stops executing as expected.</p>
<p>But wait…</p>
<p>This sounds like your maths teacher explaining integration 😵‍💫</p>
<p>So let’s understand this in <strong>our way</strong>.</p>
<hr />
<h2>When Life Breaks… JavaScript Also Breaks</h2>
<p>Imagine this:</p>
<p>You are ordering food online 🍔</p>
<p>You click <strong>“Place Order”</strong>…</p>
<p>And suddenly… nothing happens.</p>
<p>No confirmation, no error, no refund</p>
<p>Just silence…</p>
<p>That… my friend… is what we call <strong>bad error handling</strong>.</p>
<p>Now let’s bring this to code.</p>
<pre><code class="language-js">console.log(user.name);
</code></pre>
<p>But…</p>
<pre><code class="language-js">const user = null;
</code></pre>
<p>Boom 💥</p>
<p>👉 Error: Cannot read properties of null</p>
<hr />
<h2>Types of Errors (Real Life Style)</h2>
<p>JavaScript errors are mainly of 3 types:</p>
<h3>1. Syntax Error</h3>
<p>Your code is written incorrectly.</p>
<p>Like writing:</p>
<pre><code class="language-js">if (true {
  console.log("Hello");
}
</code></pre>
<p>Missing <code>)</code>… and JavaScript says:</p>
<p>👉 “Bhai pehle grammar seekh ke aa”</p>
<hr />
<h3>2. Runtime Error</h3>
<p>Code runs… but crashes during execution.</p>
<pre><code class="language-js">const user = null;
console.log(user.name);
</code></pre>
<p>This is like:</p>
<p>You reached the restaurant… but it's closed 🚪</p>
<hr />
<h3>3. Logical Error</h3>
<p>Code runs perfectly… but gives wrong result.</p>
<pre><code class="language-js">const total = 10 + "5"; // "105"
</code></pre>
<p>This is like:</p>
<p>You ordered pizza… got pineapple pizza 🍍🍕</p>
<p>Technically correct… emotionally wrong.</p>
<hr />
<h2>Now Comes the Hero — try &amp; catch</h2>
<p>So how do we handle errors?</p>
<p>JavaScript gives us a bodyguard 🛡️</p>
<p>👉 <code>try...catch</code></p>
<pre><code class="language-js">try {
  const user = null;
  console.log(user.name);
} catch (error) {
  console.log("Something went wrong");
}
</code></pre>
<hr />
<h3>How it works?</h3>
<ul>
<li><p><code>try</code> → Run risky code</p>
</li>
<li><p><code>catch</code> → Handle error if it occurs</p>
</li>
</ul>
<hr />
<h3>Real Life Example</h3>
<p>You are transferring money 💸</p>
<pre><code class="language-js">try {
  transferMoney();
} catch (error) {
  console.log("Transaction failed. Please try again.");
}
</code></pre>
<p>Instead of app crashing…</p>
<p>👉 User sees a message 👉 Business saves reputation 👉 You save your job 😅</p>
<hr />
<h2>The Flow (Important)</h2>
<p>Try to visualize this:</p>
<pre><code class="language-plaintext">Start
  ↓
try block runs
  ↓
Error?
  ↓         ↓
No          Yes
↓           ↓
skip catch  catch runs
  ↓
finally runs (always)
  ↓
End
</code></pre>
<p>Yes… there is one more player 👇</p>
<hr />
<h2>The Finally Block (The Honest Worker)</h2>
<p>No matter what happens…</p>
<p><code>finally</code> will always run.</p>
<pre><code class="language-js">try {
  console.log("Trying...");
} catch (error) {
  console.log("Error occurred");
} finally {
  console.log("I will always run 😎");
}
</code></pre>
<hr />
<h3>Real Life Example</h3>
<p>ATM Machine:</p>
<pre><code class="language-js">try {
  withdrawMoney();
} catch (error) {
  console.log("Transaction failed");
} finally {
  ejectCard(); // always happens
}
</code></pre>
<p>Even if money fails…</p>
<p>👉 Card always comes out</p>
<hr />
<h2>Throwing Custom Errors (Ab Developer Bolega 😎)</h2>
<p>Sometimes default errors are not enough.</p>
<p>We want to control the message.</p>
<pre><code class="language-js">function withdraw(amount) {
  if (amount &gt; 10000) {
    throw new Error("Limit exceeded bhai 😅");
  }
  return "Money withdrawn";
}

try {
  withdraw(20000);
} catch (error) {
  console.log(error.message);
}
</code></pre>
<hr />
<h3>Why This is Powerful?</h3>
<p>Instead of random crash…</p>
<p>👉 You define the problem 👉 You define the message 👉 You guide the user</p>
<hr />
<h2>Graceful Failure (The Real Goal)</h2>
<p>Good developers don’t write bug-free code…</p>
<p>👉 They write code that <strong>fails gracefully</strong></p>
<p>Bad Example ❌ App crashes</p>
<p>Good Example ✅ App says:</p>
<blockquote>
<p>“Something went wrong, please try again”</p>
</blockquote>
<hr />
<h2>Debugging Benefits (Why You Should Care)</h2>
<p>Error handling helps you:</p>
<ul>
<li><p>Find bugs faster 🔍</p>
</li>
<li><p>Prevent app crashes 🚫</p>
</li>
<li><p>Improve user experience ❤️</p>
</li>
<li><p>Write production-ready code 🚀</p>
</li>
</ul>
<hr />
<h2>One Small Example (Real World Combo)</h2>
<pre><code class="language-js">function login(user) {
  try {
    if (!user) {
      throw new Error("User not found");
    }

    console.log("Welcome " + user.name);

  } catch (error) {
    console.log(error.message);
  } finally {
    console.log("Login attempt finished");
  }
}

login(null);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">User not found
Login attempt finished
</code></pre>
<hr />
<h2>Final Thoughts</h2>
<p>Errors are not enemies…</p>
<p>They are signals 🚨</p>
<p>They tell you:</p>
<p>👉 “Something is wrong… fix me”</p>
<p>If you ignore them…</p>
<p>Your app becomes chaos 😵</p>
<p>If you handle them…</p>
<p>You become a real developer 💪</p>
<hr />
<h2>Homework (Don’t Run Away 😏)</h2>
<h3>Q1</h3>
<p>What will be the output?</p>
<pre><code class="language-js">try {
  console.log(a);
} catch (e) {
  console.log("Error handled");
}
</code></pre>
<hr />
<h3>Q2</h3>
<p>Fix this code using try-catch:</p>
<pre><code class="language-js">const data = JSON.parse("{name: 'Barun'}");
console.log(data);
</code></pre>
<hr />
<h3>Q3</h3>
<p>Create a function:</p>
<ul>
<li><p>If age &lt; 18 → throw error</p>
</li>
<li><p>Else → print "Access granted."</p>
</li>
</ul>
<hr />
<h2>Last Line (Important)</h2>
<p>A good developer writes code…</p>
<p>A great developer handles failure.</p>
<p>And trust me…</p>
<p>In real world…</p>
<p>Failure comes more often than success 😄</p>
<hr />
<p>Inspired by the style and storytelling approach from the shared blog examples</p>
]]></content:encoded></item><item><title><![CDATA[Nested Arrays & Flattening (The Interview Trap Explained 😏)]]></title><description><![CDATA[Alright… today we are going to talk about something which looks simple… but interviews mein logon ki hawa nikal deta hai 😏
Nested Arrays & Flattening
And trust me… if you understand this properly, yo]]></description><link>https://blog.baruntiwary.dev/nested-arrays-and-flattening-interview-guide</link><guid isPermaLink="true">https://blog.baruntiwary.dev/nested-arrays-and-flattening-interview-guide</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[array]]></category><category><![CDATA[array methods]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Sun, 22 Mar 2026 22:07:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/63b5a52a-f298-4ec8-890c-7f8a1fc0a4c8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Alright… today we are going to talk about something which looks simple… but interviews mein logon ki hawa nikal deta hai 😏</p>
<p><strong>Nested Arrays &amp; Flattening</strong></p>
<p>And trust me… if you understand this properly, you will start thinking like a developer… not like a “copy-paste engineer” 😌</p>
<p>Also… I am not going to start with heavy definitions… because honestly… <strong>kisi ko samajh nahi aata usse.</strong></p>
<hr />
<h1>So what are Nested Arrays?</h1>
<p>Technically…</p>
<p>A nested array is an array inside another array.</p>
<p>Simple? Too simple… suspiciously simple 🤨</p>
<p>Let’s understand it in our way.</p>
<hr />
<h2>Real Life Example</h2>
<p>Imagine your WhatsApp groups:</p>
<ul>
<li><p>Family Group → messages</p>
</li>
<li><p>Friends Group → messages</p>
</li>
<li><p>Office Group → messages</p>
</li>
</ul>
<p>Now if you store all groups:</p>
<pre><code class="language-plaintext">[
  ["Hi beta", "Khana khaya?"],
  ["Bhai party kab?", "Match dekha?"],
  ["Deadline kal hai", "Meeting at 10"]
]
</code></pre>
<p>This… is a <strong>nested array</strong></p>
<hr />
<h2>Visual Structure (Important)</h2>
<p>Think like this:</p>
<pre><code class="language-plaintext">[
  [1, 2],
  [3, 4],
  [5, 6]
]
</code></pre>
<ul>
<li><p>Outer array → main container</p>
</li>
<li><p>Inner arrays → sub containers</p>
</li>
</ul>
<p>Or in human language:</p>
<p>“Array ke andar aur array ghus gaya hai”</p>
<hr />
<h1>Problem Starts Here 😏</h1>
<p>Now suppose interviewer asks:</p>
<p>👉 “Give me all elements in one single array”</p>
<p>Output should be:</p>
<pre><code class="language-plaintext">[1, 2, 3, 4, 5, 6]
</code></pre>
<p>Now your brain:</p>
<p>“Easy hai bhai… dekh lenge”</p>
<p>But code likhne baithoge…</p>
<p><strong>Tab samajh aayega asli struggle 😌</strong></p>
<hr />
<h1>What is Flattening?</h1>
<p>Flattening means:</p>
<p>👉 Converting nested arrays into a single-level array</p>
<hr />
<h2>Step by Step Thinking (Very Important)</h2>
<p>Let’s take:</p>
<pre><code class="language-plaintext">const arr = [1, [2, 3], [4, [5, 6]]];
</code></pre>
<p>Now think like a developer… not like a student.</p>
<h3>Step 1: Check each element</h3>
<ul>
<li><p>1 → normal number → add</p>
</li>
<li><p>[2,3] → array → open it</p>
</li>
<li><p>[4,[5,6]] → array → open again</p>
</li>
</ul>
<hr />
<h3>Step 2: Keep opening until no array left</h3>
<p>Final result:</p>
<pre><code class="language-plaintext">[1, 2, 3, 4, 5, 6]
</code></pre>
<hr />
<h1>Why Flattening is Useful?</h1>
<p>Let’s be practical…</p>
<h3>1. API Data</h3>
<p>Sometimes backend sends:</p>
<pre><code class="language-plaintext">[["apple", "banana"], ["mango"]]
</code></pre>
<p>But frontend needs:</p>
<pre><code class="language-plaintext">["apple", "banana", "mango"]
</code></pre>
<hr />
<h3>2. E-commerce Example</h3>
<p>Orders:</p>
<pre><code class="language-plaintext">[
  ["shirt", "pant"],
  ["shoes"],
  ["watch", "belt"]
]
</code></pre>
<p>You want:</p>
<p>👉 total items sold</p>
<p>Flatten first → then count</p>
<hr />
<h3>3. Interview Favorite 😏</h3>
<p>“Flatten this array without using built-in methods”</p>
<p>And then…</p>
<p>Candidate: 😵‍💫</p>
<hr />
<h1>Different Ways to Flatten Arrays</h1>
<p>Now real game starts 🔥</p>
<hr />
<h2>1. Using flat() (Easy Mode 😌)</h2>
<pre><code class="language-plaintext">const arr = [1, [2, 3], [4, 5]];

const result = arr.flat();

console.log(result);
// [1, 2, 3, 4, 5]
</code></pre>
<h3>Deep Nested?</h3>
<pre><code class="language-plaintext">arr.flat(Infinity)
</code></pre>
<hr />
<h2>2. Using Loop (Manual Thinking 🧠)</h2>
<pre><code class="language-plaintext">const arr = [1, [2, 3], [4, 5]];
let result = [];

for (let i = 0; i &lt; arr.length; i++) {
  if (Array.isArray(arr[i])) {
    result.push(...arr[i]);
  } else {
    result.push(arr[i]);
  }
}

console.log(result);
</code></pre>
<hr />
<h2>3. Recursive Approach (Interview King 👑)</h2>
<p>Now THIS is what interviewer wants.</p>
<pre><code class="language-plaintext">function flatten(arr) {
  let result = [];

  for (let item of arr) {
    if (Array.isArray(item)) {
      result = result.concat(flatten(item));
    } else {
      result.push(item);
    }
  }

  return result;
}

const arr = [1, [2, [3, 4]], 5];

console.log(flatten(arr));
// [1, 2, 3, 4, 5]
</code></pre>
<hr />
<h3>Why recursion?</h3>
<p>Because…</p>
<p>“Array ke andar array ke andar array…”</p>
<p>Kitna andar jayega? 👉 Unknown</p>
<p>So we use recursion.</p>
<hr />
<h2>4. Using reduce()</h2>
<p>Little advanced… but sexy 😏</p>
<pre><code class="language-plaintext">const arr = [1, [2, [3, 4]], 5];

const result = arr.reduce((acc, item) =&gt; {
  return acc.concat(
    Array.isArray(item) ? flatten(item) : item
  );
}, []);

console.log(result);
</code></pre>
<hr />
<h1>Common Interview Scenarios</h1>
<p>Now listen carefully… this is gold.</p>
<hr />
<h2>Scenario 1</h2>
<p>👉 Flatten array without using <code>.flat()</code></p>
<p>Expected answer: recursion</p>
<hr />
<h2>Scenario 2</h2>
<p>👉 Flatten only one level</p>
<pre><code class="language-plaintext">[1, [2,3], [4]]
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">[1,2,3,4]
</code></pre>
<hr />
<h2>Scenario 3</h2>
<p>👉 Flatten to specific depth</p>
<pre><code class="language-plaintext">arr.flat(2)
</code></pre>
<hr />
<h2>Scenario 4</h2>
<p>👉 Count total elements in nested array</p>
<p>Hint:</p>
<p>👉 Flatten → then <code>.length</code></p>
<hr />
<h1>How to Think (Most Important Part)</h1>
<p>Whenever you see nested array:</p>
<p>Don’t panic ❌ Don’t jump to code ❌</p>
<p>Ask:</p>
<ol>
<li><p>Is this element array?</p>
</li>
<li><p>If yes → go inside</p>
</li>
<li><p>If no → collect it</p>
</li>
</ol>
<p>बस… problem solved.</p>
<hr />
<h1>Diagram Idea (Mental Visualization)</h1>
<p>Think like onion layers 🧅</p>
<pre><code class="language-plaintext">[1, [2, [3, [4]]]]
</code></pre>
<p>You keep peeling layers until:</p>
<p>👉 only numbers left</p>
<hr />
<h1>Small Assignment (Don’t Run 😏)</h1>
<pre><code class="language-plaintext">const arr = [1, [2, [3, [4, [5]]]]];
</code></pre>
<h3>Tasks:</h3>
<ol>
<li><p>Flatten this array</p>
</li>
<li><p>Count total elements</p>
</li>
<li><p>Find sum of all elements</p>
</li>
</ol>
<hr />
<h1>Final Words</h1>
<p>Nested arrays are not difficult…</p>
<p>But your thinking makes it difficult.</p>
<p>Once you understand:</p>
<p>👉 “Check → Dive → Collect”</p>
<p>You can solve ANY flatten problem.</p>
<hr />
<p>And remember…</p>
<p>Interview mein agar ye question aaya…</p>
<p>Aur aapne recursion laga diya…</p>
<p>Interviewer bolega:</p>
<p>“Yeh banda copy paste nahi karta… sochta hai” 😌🔥</p>
<hr />
<p>अब जाओ… practice करो… warna next interview mein phir bolna padega:</p>
<p>“Sir… thoda hint de dijiye…” 😭</p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Spread vs Rest in JavaScript — Ekdum Simple Bhasha Mein]]></title><description><![CDATA[So, what does Spread and Rest even mean in JavaScript?
Well technically!!!...
MDN will say something like:

Spread syntax allows an iterable to be expanded, and rest collects multiple elements into a ]]></description><link>https://blog.baruntiwary.dev/javascript-spread-vs-rest-hindi-guide</link><guid isPermaLink="true">https://blog.baruntiwary.dev/javascript-spread-vs-rest-hindi-guide</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Spread operator]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Sun, 22 Mar 2026 21:58:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/6dcde660-b897-4e7a-a438-e6cd232bdb9f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So, what does <strong>Spread</strong> and <strong>Rest</strong> even mean in JavaScript?</p>
<p>Well technically!!!...</p>
<p>MDN will say something like:</p>
<blockquote>
<p>Spread syntax allows an iterable to be expanded, and rest collects multiple elements into a single variable.</p>
</blockquote>
<p>Areee… ruk jao bhai… 😅<br />Ye sab thoda zyada “interview wali English” ho gayi.</p>
<p>Let’s understand this in our own way — the <strong>Barun style</strong>.</p>
<hr />
<h1>Spread vs Rest — Ekdum Simple Bhasha Mein</h1>
<p>👉 <strong>Spread → Expand karta hai (failata hai)</strong><br />👉 <strong>Rest → Collect karta hai (jodta hai)</strong></p>
<p>बस इतना समझ लो… aadha kaam ho gaya.</p>
<hr />
<h1>Real Life Example (Sab clear ho jayega)</h1>
<p>Socho tumhare paas ek <strong>Laddu ka dabba</strong> hai 🍬</p>
<h3>Spread kya karega?</h3>
<p>Dabba khol ke <strong>saare laddu table pe faila dega</strong></p>
<h3>Rest kya karega?</h3>
<p>Table pe pade laddu ko <strong>wapas ek dabbe me jama karega</strong></p>
<hr />
<h1>Spread Operator ( ... )</h1>
<h2>👉 Kya karta hai?</h2>
<p>Array ya object ke andar ke values ko <strong>bahar nikaal deta hai</strong></p>
<hr />
<h2>📦 Example 1: Array Expand karna</h2>
<pre><code class="language-plaintext">const numbers = [1, 2, 3];

// Without spread
console.log(numbers); 
// [1, 2, 3]

// With spread
console.log(...numbers); 
// 1 2 3
</code></pre>
<p>👉 Yaha kya hua?</p>
<p>Array toot gaya…</p>
<p>values alag alag ho gayi.</p>
<hr />
<h2>Example 2: Array Copy karna (Real Use Case)</h2>
<pre><code class="language-plaintext">const original = [1, 2, 3];
const copy = [...original];

console.log(copy);
</code></pre>
<p>👉 Ye shallow copy banata hai</p>
<p>👉 Original safe rehta hai</p>
<hr />
<h2>Example 3: Arrays Merge karna</h2>
<pre><code class="language-plaintext">const arr1 = [1, 2];
const arr2 = [3, 4];

const merged = [...arr1, ...arr2];

console.log(merged);
// [1, 2, 3, 4]
</code></pre>
<p>👉 Interview me sabse jyada poocha jaata hai 😏</p>
<hr />
<h2>Example 4: Objects me Spread</h2>
<pre><code class="language-plaintext">const user = {
  name: "Barun",
  age: 22
};

const updatedUser = {
  ...user,
  city: "Patna"
};

console.log(updatedUser);
</code></pre>
<p>👉 Old data + new data = done ✅</p>
<hr />
<h1>Rest Operator ( ... )</h1>
<h2>👉 Kya karta hai?</h2>
<p>Multiple values ko <strong>ek variable me collect karta hai</strong></p>
<hr />
<h2>Example 1: Function Arguments</h2>
<pre><code class="language-plaintext">function add(...numbers) {
  console.log(numbers);
}

add(1, 2, 3, 4);
</code></pre>
<p>👉 Output:</p>
<pre><code class="language-plaintext">[1, 2, 3, 4]
</code></pre>
<p>👉 Sab values ek array me aa gayi</p>
<hr />
<h2>Example 2: Destructuring me Rest</h2>
<pre><code class="language-plaintext">const numbers = [1, 2, 3, 4];

const [first, ...rest] = numbers;

console.log(first); // 1
console.log(rest);  // [2, 3, 4]
</code></pre>
<p>👉 First alag</p>
<p>👉 Baaki sab ek bundle me</p>
<hr />
<h1>Spread vs Rest — Difference Samjho</h1>
<table>
<thead>
<tr>
<th>Feature</th>
<th>Spread</th>
<th>Rest</th>
</tr>
</thead>
<tbody><tr>
<td>Kaam</td>
<td>Expand karna</td>
<td>Collect karna</td>
</tr>
<tr>
<td>Direction</td>
<td>Inside → Outside</td>
<td>Outside → Inside</td>
</tr>
<tr>
<td>Use case</td>
<td>Copy, merge</td>
<td>Function args, destructuring</td>
</tr>
</tbody></table>
<hr />
<h1>Visual Soch (Diagram Type Samajh)</h1>
<h3>Spread</h3>
<pre><code class="language-plaintext">[1, 2, 3]  →  1  2  3
</code></pre>
<h3>Rest</h3>
<pre><code class="language-plaintext">1  2  3  →  [1, 2, 3]
</code></pre>
<hr />
<h1>Real World Use Cases (Important hai bhai)</h1>
<hr />
<h2>✅ 1. React me State Update</h2>
<pre><code class="language-plaintext">const user = {
  name: "Barun",
  age: 22
};

const updated = {
  ...user,
  age: 23
};
</code></pre>
<p>👉 Direct mutation nahi</p>
<p>👉 Clean update</p>
<hr />
<h2>✅ 2. Function me Unlimited Parameters</h2>
<pre><code class="language-plaintext">function totalPrice(...prices) {
  return prices.reduce((a, b) =&gt; a + b);
}
</code></pre>
<p>👉 Shopping cart jaisa system</p>
<hr />
<h2>✅ 3. API Data Merge</h2>
<pre><code class="language-plaintext">const apiData = { name: "Barun" };
const extraData = { role: "Developer" };

const final = { ...apiData, ...extraData };
</code></pre>
<p>👉 Backend + frontend data combine</p>
<hr />
<h1>Golden Rule (Yaad rakhna)</h1>
<p>👉 Jab <strong>failana ho → Spread</strong></p>
<p>👉 Jab <strong>jama karna ho → Rest</strong></p>
<hr />
<h1>Common Confusion</h1>
<pre><code class="language-plaintext">function test(...args) {}  // Rest

const arr = [...numbers]; // Spread
</code></pre>
<p>👉 Same <code>...</code></p>
<p>👉 Kaam alag</p>
<hr />
<h1>🧪 Mini Assignment (Dimaag chalao)</h1>
<h2>Q1</h2>
<pre><code class="language-plaintext">const arr1 = [1, 2];
const arr2 = [3, 4];

const result = [...arr1, 5, ...arr2];
console.log(result);
</code></pre>
<hr />
<h2>Q2</h2>
<pre><code class="language-plaintext">function test(a, b, ...rest) {
  console.log(rest);
}

test(1, 2, 3, 4, 5);
</code></pre>
<hr />
<h2>Q3 (Thoda tricky 😏)</h2>
<pre><code class="language-plaintext">const [a, ...b] = [10, 20, 30, 40];

console.log(a);
console.log(b);
</code></pre>
<hr />
<h1>Final Words</h1>
<p>Spread aur Rest dono ek hi family ke hai…</p>
<p>Bas ek <strong>extrovert hai (Spread)</strong></p>
<p>aur ek <strong>introvert hai (Rest)</strong> 😅</p>
<p>Ek duniya me values failata hai</p>
<p>Dusra sabko ek jagah jama karta hai</p>
<hr />
<p>Agar ye concept clear ho gaya na…</p>
<p>Toh aapka JavaScript ka level</p>
<p>“just learning” se</p>
<p>“developer thinking” me shift ho gaya 🚀</p>
<hr />
<p>Chalo ab sach sach batao…</p>
<p>Pehle confuse the ya ab clear hai? 😏</p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Modules: Because Your 1000-Line File Deserves Therapy]]></title><description><![CDATA[Let’s be honest.
At some point in your JavaScript journey, you created that one file.
You know the one.

1000+ lines

Variables named data2, finalData, finalFinalData

Functions doing 7 different thin]]></description><link>https://blog.baruntiwary.dev/javascript-modules-because-your-1000-line-file-deserves-therapy</link><guid isPermaLink="true">https://blog.baruntiwary.dev/javascript-modules-because-your-1000-line-file-deserves-therapy</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[javascript modules]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Thu, 19 Mar 2026 08:27:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/4278db42-32a5-4455-8b0a-6069e39a0ff8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let’s be honest.</p>
<p>At some point in your JavaScript journey, you created that <em>one file</em>.</p>
<p>You know the one.</p>
<ul>
<li><p>1000+ lines</p>
</li>
<li><p>Variables named <code>data2</code>, <code>finalData</code>, <code>finalFinalData</code></p>
</li>
<li><p>Functions doing 7 different things</p>
</li>
<li><p>And a comment at the top:<br />// TODO: clean this later</p>
</li>
</ul>
<p>Congratulations. You’ve experienced life <em>before modules</em>.</p>
<p>Let’s fix that.</p>
<hr />
<h2>Why Are Modules Needed?</h2>
<p>Imagine running a startup where:</p>
<ul>
<li><p>The CEO is also the developer</p>
</li>
<li><p>The developer is also the HR</p>
</li>
<li><p>The HR is also the chai wala</p>
</li>
</ul>
<p>That’s exactly what your JavaScript file becomes without modules.</p>
<p>Everything is dumped into one place.</p>
<h3>The Problems Start Like This:</h3>
<ol>
<li><p>Naming conflicts<br />You create a function called <code>calculate()</code>.<br />Your teammate also creates a function called <code>calculate()</code>.<br />Boom. One overrides the other. Debugging begins. Tears follow.</p>
</li>
<li><p>No structure<br />Authentication logic sits next to UI code, sitting next to API calls.<br />It’s like putting your toothbrush in the fridge and milk in your cupboard.</p>
</li>
<li><p>Hard to maintain<br />You change one thing → five things break.<br />Now you're afraid to even press Ctrl + S.</p>
</li>
</ol>
<hr />
<h2>Enter Modules (Your Code’s Personal Organizer)</h2>
<p>Modules help you break your code into smaller, meaningful pieces.</p>
<p>Instead of one giant file, you get:</p>
<ul>
<li><p><code>auth.js</code></p>
</li>
<li><p><code>api.js</code></p>
</li>
<li><p><code>utils.js</code></p>
</li>
<li><p><code>main.js</code></p>
</li>
</ul>
<p>Each file has a <em>clear responsibility</em>.</p>
<p>Think of modules like different rooms in a house:</p>
<ul>
<li><p>Kitchen → cooking</p>
</li>
<li><p>Bedroom → sleeping</p>
</li>
<li><p>Bathroom → don’t ask questions</p>
</li>
</ul>
<p>Everything has a place.</p>
<hr />
<h2>Exporting Functions or Values</h2>
<p>Now that you've split your code, you need a way to share things between files.</p>
<p>That’s where <strong>exports</strong> come in.</p>
<h3>Example:</h3>
<pre><code class="language-javascript">// math.js

export function add(a, b) {
  return a + b;
}

export const PI = 3.14;
</code></pre>
<p>Here, we are saying:</p>
<p>"Hey world, you can use <code>add</code> and <code>PI</code> from this file."</p>
<hr />
<h2>Importing Modules</h2>
<p>Now let’s use those exported things somewhere else.</p>
<pre><code class="language-js">// app.js

import { add, PI } from './math.js';

console.log(add(2, 3)); // 5
console.log(PI); // 3.14
</code></pre>
<p>Simple.</p>
<p>You export from one file and import into another.</p>
<p>It’s like ordering food from another room instead of cooking everything yourself.</p>
<hr />
<h3><strong>Default vs Named Exports</strong></h3>
<p>This is where most people get confused. Let’s clear it once and for all.</p>
<p><strong>Named Exports</strong></p>
<p>You can export multiple things.</p>
<pre><code class="language-javascript">// utils.js

export const greet = () =&gt; "Hello"; 

export const bye = () =&gt; "Goodbye";
</code></pre>
<p>Import them like this:</p>
<pre><code class="language-javascript">import { greet, bye } from './utils.js';
</code></pre>
<p>Names must match exactly.</p>
<p>No drama allowed.</p>
<hr />
<p>Default Export</p>
<p>You can export one main thing.</p>
<pre><code class="language-javascript">// logger.js
export default function log(message) {
  console.log(message);
}
</code></pre>
<p>Import it like this:</p>
<pre><code class="language-javascript">import log from './logger.js';
</code></pre>
<p>Notice:</p>
<ul>
<li><p>No curly braces</p>
</li>
<li><p>You can rename it</p>
</li>
</ul>
<pre><code class="language-javascript">import anythingYouWant from './logger.js';
</code></pre>
<p>JavaScript doesn't care. It’s chill like that.</p>
<hr />
<h3>Real-Life Analogy</h3>
<p>Think of it like this:</p>
<p>Named exports = multiple people in a group chat</p>
<p>Default export = that one friend who always speaks for everyone</p>
<hr />
<h3>Benefits of Modular Code</h3>
<p>Now let’s talk about why this actually matters.</p>
<ol>
<li><strong>Maintainability</strong></li>
</ol>
<p>Instead of digging through a jungle, you know exactly where things live.</p>
<p>Bug in authentication?</p>
<p>Go to <code>auth.js</code> . Done.</p>
<ol>
<li><strong>Reusability</strong></li>
</ol>
<p>Write once, use everywhere.</p>
<p>Your <code>formatDate()</code> function can now travel across files like a freelancer.</p>
<ol>
<li><strong>Readability</strong></li>
</ol>
<p>A new developer joins your project.</p>
<p>Instead of saying:</p>
<p>"Yeah, bro, everything is in index.js."</p>
<p>You can say:</p>
<p>"Check the modules. It's structured."</p>
<p>Now you look professional.</p>
<ol>
<li><strong>Scalability</strong></li>
</ol>
<p>Your project grows.</p>
<p>Without modules → chaos grows faster</p>
<p>With modules → structure grows with it</p>
<ol>
<li><strong>Debugging Becomes Less Painful</strong></li>
</ol>
<p>Smaller files = smaller problems</p>
<p>Instead of:</p>
<p>"Something broke somewhere."</p>
<p>You get:</p>
<p>"Something broke here."</p>
<p>Big difference.</p>
<hr />
<h3>Final Thoughts</h3>
<p>Modules don’t just organize your code.</p>
<p>They save your future self from suffering.</p>
<p>Because trust me:</p>
<p>Future you will open your old project and say, "Who wrote this garbage?"</p>
<p>And the answer will be: You.</p>
<p>So do yourself a favor.</p>
<p>Use modules.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding JavaScript Objects the Fun Way (Marks, Parents & Survival 😅)JavaScript]]></title><description><![CDATA[So, what does Objects means?
Well technically!!!...
MdN
The Object type represents one of JavaScript's data types. It is used to store various keyed collections and more complex entities. Objects can ]]></description><link>https://blog.baruntiwary.dev/what-is-javascript-object-explained-with-examples</link><guid isPermaLink="true">https://blog.baruntiwary.dev/what-is-javascript-object-explained-with-examples</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Objects]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Wed, 18 Mar 2026 10:04:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/ceda4c25-8ec4-411c-9eb7-c408966759f5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So, what does Objects means?</p>
<p>Well technically!!!...</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">MdN</a></p>
<p>The <code>Object</code> type represents one of <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Data_structures">JavaScript's data types</a>. It is used to store various keyed collections and more complex entities. Objects can be created using the <code>Object()</code> constructor or the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer">object initializer / literal syntax</a>.</p>
<p>This was way to technicall, right? So let's understand it in our own way.</p>
<p>In Simple Words, an object is a <strong>non-primitive</strong> data type that can store data in the <strong>key : pair</strong> format, within <strong>curly brackets</strong>.</p>
<p>Examples:</p>
<pre><code class="language-javascript">const marks = {
    english: 34,
    maths:56,
    science: 40,
    hindi: 80,
    computer: 98,
    computers: 98
}
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/e2838655-8e22-4b53-93ed-cb498900340a.png" alt="" />

<p>Yes, I know that I am more skilled at computers than in other subjects. But it doesn't mean other subjects are not important, but we have an unknown relationship with Computers. At least I do have it.</p>
<p>So, I got 34 in English, 56 in Maths, 40 in Science, 80 in Hindi, and 98 in Computer. But I don't know why the college has given me computer marks 2 time. No problem, we will see this later on and for the time beign we will ignore that.</p>
<p>How do we store this data in JS or in any other programming language?</p>
<p>In a variable?</p>
<img src="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/1ef77f75-8c31-4749-8660-6af675469bd0.png" alt="" />

<p>Then, what if we have to add a few more subject marks?</p>
<p>We have to create more variables, right? Is it the most efficient way? No</p>
<p>So, the array should work right because it is built to store similar data into one place, right?</p>
<img src="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/af879847-b96b-4ce8-87d2-2169c5b166cf.png" alt="" />

<p>Just the array for marks will confuse that, which marks belong to which subject. So, we also need to have the subjects array and store subjects' names in the same order as the marks is stored.</p>
<p>And this will make more complications because to update the marks or to add any new subject marks, we have to make sure that both the variable or array sync with each other. And we have to manage two different variables.</p>
<p>So, then objects come into the picture.</p>
<pre><code class="language-javascript">const marks = {};
</code></pre>
<p>It can be created in multiple ways, but we are going to see some common ones.</p>
<p>The above code you can see is what we call variable initialisation or object literal. Which means first, we are declaring the variable with a name <code>marks</code> , and we are assigning the empty object with curly braces.</p>
<p>Now that we have created an empty object, how would we store the information and retrieve it?</p>
<p>There are mainly two ways to do that:</p>
<ol>
<li><p>Using square brackets <code>[]</code></p>
</li>
<li><p>Using dot <code>.</code> notation.</p>
</li>
</ol>
<p>We will see both one by one.</p>
<h4>Square brackets.</h4>
<pre><code class="language-javascript">const marks = {
    english: 34,
    maths:56,
    science: 40,
    hindi: 80,
    computer: 98
}


console.log(marks['english']);
console.log(marks['math']);
console.log(marks['science']);
console.log(marks['hindi']);
console.log(marks['computer']);
</code></pre>
<p><strong>Dot Notations.</strong></p>
<pre><code class="language-javascript">
const marks = {
    english: 34,
    maths:56,
    science: 40,
    hindi: 80,
    computer: 98
}

console.log(marks.english);
console.log(marks.math);
console.log(marks.science);
console.log(marks.hindi);
console.log(marks.computer);
</code></pre>
<blockquote>
<p>Key name with spacing will not work in dot notation. It will only work in square bracket notation.</p>
</blockquote>
<p>40 is the minimum passing mark. I failed in English and just passed in science.</p>
<p>I got the marks 😱😰, and it's time to show this to devils 👿 (aree bhai itna bhi nhi samjte - parents - kya gunda bana ga ree tu).</p>
<p>But can I show this to my parents?</p>
<p>Wish me RIP ☠️...</p>
<p>But wait..... a minute.......</p>
<p>Is there any way that I could change the marks I obtained?</p>
<p>I guess so, then let's dive into how to update the object value and save my life from the devils.</p>
<pre><code class="language-javascript">const marks = {
    english: 34,
    maths:56,
    science: 40,
    hindi: 80,
    computer: 98
}

console.log("++++++++++++++")

// Lets save ourself by dot notation
marks.english = 49
marks.science = 48

console.log(marks.english);
console.log(marks.science);

// Lets save ourself by square bracket notation
marks['english'] = 50;
marks['science'] = 49;

console.log(marks['english']);
console.log(marks['science']);
</code></pre>
<p>Nice, just like we access the data from the object, we can also update the values. So, now I get a little bit of relief.</p>
<p>Now, college is college; they are saying that we have to give you the marks, and create your marksheet by yourself.</p>
<p>In My Mind: Well, good, I wanted that only.</p>
<p>But here is the problem, they have given me <code>computer</code> marks two times with extra <code>s</code> letter with one of the marks.</p>
<p>So, how could we remove that?</p>
<p><code>delete</code> A keyword that you will find in almost all programming languages for deleting things at runtime from the memory.</p>
<p>So, how to use that?</p>
<pre><code class="language-javascript">const marks = { 
    english: 34, 
    maths:56, 
    science: 40, 
    hindi: 80, 
    computer: 98, 
    computers: 98 
}

delete marks['computers']; // yes you can use dot notation as well  `delete marks.computers;

console.log(marks);
</code></pre>
<p>So let's iterate through this <code>marks</code> object and try to create a report card now.</p>
<p>There are a couple of ways to loop through this object. We are going to see an uncommon way of doing that.</p>
<h4>Object.entries()</h4>
<p><code>.entries()</code> It is the static method in Global <code>Object</code> that helps to convert the object into arrays.</p>
<p>Each key and value pair is converted into an array of 2 elements. The first element is the key, and the second element is the array.</p>
<p>Now all this 2 elements array are wrapped inside another array.</p>
<pre><code class="language-javascript">const marks = { 
    english: 34, 
    maths:56, 
    science: 40, 
    hindi: 80, 
    computer: 98,
}

const marks_array = Object.entries(marks);
console.log(marks_array);
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/468d0de0-ce4b-48b8-af1d-2975525a6aa3.png" alt="" />

<p>Now we can iterate through <code>marks_array</code> , as it is easy to iterate through an array in comparison to objects.</p>
<pre><code class="language-javascript">const marks = { 
    english: 34, 
    maths:56, 
    science: 40, 
    hindi: 80, 
    computer: 98,
}

const marks_array = Object.entries(marks);

// Instead of [key, value] we can also write mark
// and can access the value like mark[0], mark[1]
// where mark[0] - key and mark[1] - value
// try to print the value of [key, value] inside the loop.
console.log("Barun Tiwary Report Card");
for (const [key, value] in marks_array) {
    console.log(`\({key.toUpperCase()}: \){value}`);
}

console.log("Barun is one of our very hard working student");
console.log("Please ask his friends to read the blog");
console.log("We are proud to tell that he studies in our college");
console.log("Principal: Ganja Dakla");
</code></pre>
<h2>JavaScript Objects – Assignments</h2>
<hr />
<h3>Assignment 1: Create &amp; Access Student Data</h3>
<p><strong>Objective</strong></p>
<ul>
<li><p>Understand object creation</p>
</li>
<li><p>Learn dot vs bracket notation</p>
</li>
<li><p>Work with key-value pairs</p>
</li>
</ul>
<p><strong>Question</strong></p>
<p>Create an object called <code>studentMarks</code> with the following data:</p>
<ul>
<li><p>english → 45</p>
</li>
<li><p>maths → 67</p>
</li>
<li><p>science → 52</p>
</li>
<li><p>computer science → 90 (note the space in key)</p>
</li>
</ul>
<p><strong>Tasks</strong></p>
<ol>
<li><p>Print all values using dot notation</p>
</li>
<li><p>Print all values using bracket notation</p>
</li>
<li><p>Try accessing "computer science" using dot notation</p>
<ul>
<li>What happens? Why?</li>
</ul>
</li>
<li><p>Fix it using the correct method</p>
</li>
</ol>
<hr />
<h3>Assignment 2: Update, Delete &amp; Fix the Data</h3>
<p><strong>Objective</strong></p>
<ul>
<li><p>Learn updating values</p>
</li>
<li><p>Delete properties</p>
</li>
<li><p>Handle mistakes in objects</p>
</li>
</ul>
<p><strong>Question</strong></p>
<p>Given this object:</p>
<pre><code class="language-js">const marks = {
  english: 34,
  maths: 56,
  science: 40,
  hindi: 80,
  computer: 98,
  computers: 98
};
</code></pre>
<p><strong>Tasks</strong></p>
<ol>
<li><p>Update:</p>
<ul>
<li><p>english → 50</p>
</li>
<li><p>science → 49</p>
</li>
</ul>
</li>
<li><p>Delete the incorrect key (<code>computers</code>)</p>
</li>
<li><p>Add a new subject:</p>
<ul>
<li>history → 77</li>
</ul>
</li>
<li><p>Print the final object</p>
</li>
</ol>
<hr />
<h3>Assignment 3: Build a Report Card System</h3>
<p><strong>Objective</strong></p>
<ul>
<li><p>Learn Object.entries()</p>
</li>
<li><p>Loop through objects</p>
</li>
<li><p>Apply real-world logic</p>
</li>
</ul>
<p><strong>Question</strong></p>
<p>Using this object:</p>
<pre><code class="language-js">const marks = {
  english: 50,
  maths: 56,
  science: 49,
  hindi: 80,
  computer: 98
};
</code></pre>
<p><strong>Tasks</strong></p>
<ol>
<li><p>Convert the object into an array using <code>Object.entries()</code></p>
</li>
<li><p>Loop through it and print:</p>
</li>
</ol>
<pre><code class="language-plaintext">ENGLISH: 50
MATHS: 56
</code></pre>
<ol>
<li><p>Add logic:</p>
<ul>
<li><p>If marks &lt; 40 → print "Fail"</p>
</li>
<li><p>Else → print "Pass"</p>
</li>
</ul>
</li>
</ol>
<p>Example:</p>
<pre><code class="language-plaintext">ENGLISH: 50 - Pass
SCIENCE: 49 - Pass
</code></pre>
<ol>
<li><p>Print a final message:</p>
<ul>
<li><p>"Student has successfully passed the exam"</p>
</li>
<li><p>Or failed if any subject &lt; 40</p>
</li>
</ul>
</li>
</ol>
<hr />
<h2>Bonus Challenge</h2>
<ol>
<li><p>Calculate average marks</p>
</li>
<li><p>Find highest scoring subject</p>
</li>
<li><p>Find lowest scoring subject</p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[JavaScript Arrays 101]]></title><description><![CDATA[So what do you mean by arrays, actually? Technically, an array is a collection of multiple data items of the same data type in one variable, but do you really get this?
Consider Arrays as the album in]]></description><link>https://blog.baruntiwary.dev/javascript-arrays-101</link><guid isPermaLink="true">https://blog.baruntiwary.dev/javascript-arrays-101</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[arrays]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Thu, 12 Mar 2026 20:05:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/46aacc97-4cc2-4026-a174-2cfe4a6665d0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So what do you mean by <strong>arrays,</strong> actually? Technically, an array is a collection of multiple data items of the same data type in one variable, but do you really get this?</p>
<p>Consider Arrays as the album in your music app where you store all your favourite music. It only contains your favourite music lists. This sounds a little familiar, right?</p>
<p>So, now you want a new set of albums in your music app that will store only music designed to help you feel calm and be more productive while you work. Now, what do you generally do? Obviously, Barun, we can create a new album where we will be storing all the calm, mindfulness, and meditation kind of music, which improves my productivity.</p>
<p>Exactly, unknowingly you have just created an array (Album) which contains all your music (data of the same type - category) related to work in one place.</p>
<p>Now, let's understand technically what an array is in JavaScript. As javascript have different sets of data types, which are Number, String, Boolean, Undefined, Null, Symbol, etc and at some point in time we need to store all the related data into a single place. So, where do we store all that data? YES, the answer is an array. Although we have other <a href="https://www.geeksforgeeks.org/dsa/data-structure-meaning/">data structures</a> where we can store similar data, but todays topic will only move around Array.</p>
<p>Now let's deep dive into the code.</p>
<p>The question is, how can we create an Array?</p>
<p>The code below explains how we create an array in JS.</p>
<pre><code class="language-javascript">// Creating an empty array named `empty_array`, you can name this anything, whatever you like, like masti_album;
const empty_array = [];

// Creating an array, which stores all the songs which you listent on the regular basis, named `regular_album`. Again, you can name this anything.
const regular_album = ['Balam Pichkari', 'Jhumka Gira Re', 'Dum Maro Dum', 'Didi Tera Devar Deewana', 'Saiyaara', 'Aavan Jaavan'];
</code></pre>
<p>So, in the above code, we have created 2 different arrays.</p>
<p>The first array is empty; it doesn't contain any songs. The second array contains the regular song names, which are of the string data type.</p>
<p>Now, if I ask you, tell me in the <code>regular_album</code> list, the song name <strong>'Jhmka Jira Re'</strong> is in which place?</p>
<p>You would answer that it is in the 2nd place, right?</p>
<p>Well !!!...</p>
<p>Technically, you are correct, but technically, you are not 😅😅😅.</p>
<p>Areee... don't be so confused. I was just kidding. But on a serious note. You are wrong.</p>
<p>Technically, in JavaScript or even in any other programming language, the counting (Indexing) in the array starts from 0. So, the <strong>'Jhumka Gira Re',</strong> the <strong>2nd element</strong> in the arrays, is in the <strong>1st index.</strong></p>
<p><strong>Element</strong> and <strong>Index</strong> are two different things.</p>
<ol>
<li><p>An element is data</p>
</li>
<li><p>An index is where that element(data) is positioned</p>
</li>
</ol>
<p>And this position or index starts from 0 in the array.</p>
<p>So, now if I ask you, <strong>'Saiyaara'</strong>, is in which position or index, then what is your answer?</p>
<p>Aree <strong>Uncle and Aunties</strong>, not in 5th position,</p>
<p><strong>'Saiyaara'</strong> is the data, and the data is stored in the 4th index or position, because the index starts from 0. And if we start counting the position of this song from 0 in the <code>regular_album</code> array, then its position comes 4.</p>
<p>That means the index of this song is 4th, not 5th.</p>
<p>So, lets see how to access the element and perform some operations in it, in code.</p>
<pre><code class="language-javascript">const regular_album = ['Balam Pichkari', 'Jhumka Gira Re', 'Dum Maro Dum', 'Didi Tera Devar Deewana', 'Saiyaara', 'Aavan Jaavan'];
</code></pre>
<p>Above, I have defined the array as we discussed in the last example.</p>
<p>Now let's print the <strong>2nd</strong> <strong>element,</strong> not the <strong>index</strong>. So, first, tell me what's the value of the 2nd element?</p>
<pre><code class="language-javascript">// regular_album[1] = "Jhumka Gira Re"
console.log(regular_album[1]);
</code></pre>
<p>1st element = 0 index</p>
<p>2nd element = 1 index</p>
<p>3rd element = 2 index</p>
<p>Likewise, when we go to the 2nd element, which is stored in the 1st index. Then, our final output of the code will be <code>Jhumka Gira Re</code></p>
<p>Ohh god, I listen to the same song in the repeat mode for decades just like <a href="https://x.com/nirudhuuu/status/2032087493580108286">Anirudh Bhiaya</a> listens. Now I also want to move on and replace my old regular songs with new ones. So, how should I do it?</p>
<p>Let's learn this.</p>
<p>As we already know, using the square bracket just after the variable name in which the array is stored with the index value, we can access the element at that index. In the same way, we can replace the old value with a new one.</p>
<p>Do you wanna see??</p>
<p>Really, do you wanna update your old and clumsy regular song with a new one?</p>
<p>So, just follow along with the code.</p>
<pre><code class="language-javascipt">// Creating an empty array named `empty_array`, you can name this anything, whatever you like, like masti_album;
const empty_array = [];

// Creating an array, which stores all the songs which you listent on the regular basis, named `regular_album`. Again, you can name this anything.
const regular_album = ['Balam Pichkari', 'Jhumka Gira Re', 'Dum Maro Dum', 'Didi Tera Devar Deewana', 'Saiyaara', 'Aavan Jaavan'];

// Holi season has passed on and you want to replace 'Balam Pichkari' with something new, just like below.
regular_album[0] = 'Dancing with ghost';

console.log(regular_album);
</code></pre>
<p>Ohh.. god, I taught you how to replace your old song with a new one. Now you can update any song in the same way. Have <strong>FUN!!!...</strong></p>
<p>You always listen to the list of songs, but do you really know how many songs you listen to on a daily basis??</p>
<p>No?</p>
<p>I knew it, I knew it.</p>
<p>Don't worry, we have something called <code>length</code> property in the array, which can help us count the total number of elements in the array list. So, using that, we can count how many total songs are in your playlists.</p>
<p>Let's do it, guys</p>
<pre><code class="language-javascript"> // Creating an empty array named `empty_array`, you can name this anything, whatever you like, like masti_album;
const empty_array = [];

// Creating an array, which stores all the songs which you listent on the regular basis, named `regular_album`. Again, you can name this anything.
const regular_album = ['Dancing with ghost', 'Jhumka Gira Re', 'Dum Maro Dum', 'Didi Tera Devar Deewana', 'Saiyaara', 'Aavan Jaavan'];

// Total Songs you listen on daily basis.
console.log(regular_album.length) // Output: 6
</code></pre>
<blockquote>
<p>Total Element in the Array = last index + 1</p>
<p>or vise versa</p>
<p>Last Index = Total Element in the Array - 1</p>
<p>['Dancing with ghost', 'Jhumka Gira Re', 'Dum Maro Dum', 'Didi Tera Devar Deewana']</p>
<p>0 index, 1 index 2 index 3 index</p>
<p>Total Length = 4</p>
</blockquote>
<hr />
<p>Ok, I taught you a couple of things like:</p>
<ol>
<li><p>How is your list of songs stored effectively in one place?</p>
</li>
<li><p>How are your old songs replaced with new ones under the hood?</p>
</li>
<li><p>How do you get to know how many songs you listent in a day?</p>
</li>
</ol>
<p>But still, you should have a question in your mind about how your songs are played one by one, right?</p>
<p>No!!!</p>
<p>You didn't think about that?</p>
<p>What are your thinking capabilities, <strong>Uncle &amp; Aunties</strong>? Where are you thinking?</p>
<p>AI has ruined your thinking capability.</p>
<p>But no worries, I am here to recover that only. I have taken the "Thaka" of teaching you guys, so here I am.</p>
<p>Let's learn how to do that!!!</p>
<p>So, below is the code for iterating (looping) your song. Or how your songs are beign played one by one.</p>
<pre><code class="language-javascript">const songs = [];


const songs = ['Dancing with ghost', 'Jhumka Gira Re', 'Dum Maro Dum', 'Didi Tera Devar Deewana', 'Saiyaara', 'Aavan Jaavan'];


for (let i = 0; i &lt; songs.length; i++) {
    console.log(reglar_album[i]);
}
</code></pre>
<p><strong>Dry Run:</strong></p>
<pre><code class="language-text">songs = ['Dancing with ghost', 'Jhumka Gira Re', 'Dum Maro Dum', 'Didi Tera Devar Deewana', 'Saiyaara', 'Aavan Jaavan'];

Loop:
----

i        i &lt; songs.length        output(songs[i])            i++
--       ----------------        ----------------            ---
0        0 &lt; 6                   'Dancing with ghost'        0
1        1 &lt; 6                   'Jhumka Gira Re'            1
2        2 &lt; 6                   'Dum Maro Dum'              2
3        3 &lt; 6                   'Didi Tera Devar Deewana'   3
4        4 &lt; 6                   'Saiyaara'                  4
5        5 &lt; 6                   'Aavan Jaavan'              5
6        6 &lt; 6                   Loop Breaks;
</code></pre>
<p>Now, if you still can't understand how your songs are being played, <strong>then</strong> <strong>God saves</strong> you in this hardcore world in the AI ERA.</p>
<h3>Yes, Homework… Don’t Run Away 😏</h3>
<p>Alright Uncle &amp; Aunties…<br />Enough theory. Enough songs. Enough blaming AI for everything.</p>
<p>Now it's <strong>your turn to prove that your brain is still working.</strong></p>
<p>We are going to do the <strong>same thing we did with songs</strong>, but this time with <strong>movies</strong>.</p>
<p>Why movies?</p>
<p>Because let's be honest…<br />You probably remember movie names faster than JavaScript concepts.</p>
<p>So let's start.</p>
<ol>
<li><h3>Create Your Movie Album</h3>
<p>Create an array called <code>favourite_movies</code> movies that stores <strong>5 movie names</strong> that you really like.</p>
<p>But wait… make sure you actually have <strong>exactly 5 elements</strong> in the array.</p>
<p>Not 4.<br />Not 6.</p>
<p>JavaScript will not complain, but your teacher might.</p>
</li>
<li><h3>Find the First Movie</h3>
<p>Print the <strong>first movie</strong> from the array.</p>
<p>Remember something important:</p>
<p>Arrays in JavaScript <strong>do not start counting from 1</strong>.</p>
<p>If you start counting from 1… your code will politely give you the wrong answer.</p>
</li>
<li><h3>Find the Last Movie (Without Hardcoding)</h3>
<p>Print the <strong>last movie in the array</strong>.</p>
<p>But here is the rule:</p>
<p>You are <strong>NOT allowed to directly write the index number</strong>.</p>
<p>Meaning this is <strong>not allowed</strong>:</p>
<pre><code class="language-plaintext">favourite_movies[4]
</code></pre>
<p>Your code should still work even if someone later adds <strong>more movies</strong> to the array.</p>
<p>Think carefully.</p>
<p>JavaScript has already told you how many elements exist.</p>
</li>
<li><h3>Replace One Movie</h3>
<p>Assume you got bored of one movie.</p>
<p>Replace the <strong>3rd movie</strong> in the array with a new movie name of your choice.</p>
<p>Small brain teaser:</p>
<p>The question says <strong>3rd movie</strong>.</p>
<p>But arrays <strong>start from 0</strong>.</p>
<p>So choose the index carefully or your replacement will happen somewhere else.</p>
</li>
<li><h3>Print All Movies One by One</h3>
<p>Use a <code>for</code> loop to print <strong>every movie in the array</strong>.</p>
<p>But here is the tiny trap:</p>
<p>Your loop should <strong>not try to access an index that does not exist</strong>.</p>
<p>If your loop runs one extra time, JavaScript will happily print <code>undefined</code>.</p>
<p>Which means your loop condition is wrong.</p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[JavaScript Operators: The basics you need to know.]]></title><description><![CDATA[Operators
Operators are the way to perform mathematical operations in any programming language, and yes, JavaScript also has many of them.
Generally, there are at most 3 types of operators

Arithmetic]]></description><link>https://blog.baruntiwary.dev/javascript-arithmetic-relational-logical-operators</link><guid isPermaLink="true">https://blog.baruntiwary.dev/javascript-arithmetic-relational-logical-operators</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[chaicode webdev cohort 2026]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Wed, 11 Mar 2026 19:37:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/3bc334de-3a22-4239-a51c-109d53dd2f2c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3>Operators</h3>
<p>Operators are the way to perform mathematical operations in any programming language, and yes, JavaScript also has many of them.</p>
<p>Generally, there are at most 3 types of operators</p>
<ol>
<li><p>Arithmetical operators</p>
</li>
<li><p>Logical Operators</p>
</li>
<li><p>Relational Operators</p>
</li>
</ol>
<p>You will find many others as well, but most will be in one of the types above.</p>
<h4>Arithmetical Operators</h4>
<p>These are the operators that perform mathematical operations such as addition and subtraction.</p>
<blockquote>
<p>% is not percentage in programming. It is called modulus (returns the remainder).</p>
</blockquote>
<p>Some operators:</p>
<ol>
<li><p>[ + ] Addition</p>
</li>
<li><p>[ - ] Subtraction</p>
</li>
<li><p>[ * ] Multiplication</p>
</li>
<li><p>[ / ] Multiplication</p>
</li>
<li><p>[ % ] Modulus</p>
</li>
</ol>
<p>All the above operators you would have used in your life, right, so I'm just explaining about the modulus (%) operator</p>
<img src="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/595cab2f-83df-4869-8ebc-41acb88b5f70.png" alt="" />

<p>In the above image, as you can see, I have done a simple division, which we learn in our schools.</p>
<p>So the answer is <code>25 / 2 = 12.5</code> right, which we also called Quotient in Division. But in modulus, we divide the number until we get the remainder (Integer Quotient, not decimal), and then the remainder, which we get, is the final result of modulus.</p>
<p>We use modulus in the same way we use division; just in case of modulus, we replace the division symbol (/) with the modulus symbol (%).</p>
<p>Now we also have Unary Operator, which comes under the Arithmetic Operators. Unary Operator means the operator which perform action with just a sinlge operands.</p>
<blockquote>
<p>In programming operands means a variable, constant , value or expression on which operations can be performed by operators.</p>
<p>Like In:</p>
<p>const cirecleArea = 2 * Math.pi <em>* r ^ 2;</em></p>
<p><em>const squareArea = ( length +</em> breadth <em>) * 2</em></p>
<p>In above code 2, Math.pi, length, breadth are the operand in which operations are performed by operators.</p>
</blockquote>
<p>Unary Operators have 2 things with them</p>
<ol>
<li><p>The symbols, which are the Increment Operator ( ++ ) and the Decrement Operator ( -- )</p>
</li>
<li><p>Position of these Operators: Prefix (Before the operand) and Postfix (After the operand)</p>
</li>
</ol>
<p>First, lets undertstand the concept of positions.</p>
<p>When we write something like <code>++a</code> In our code, it represents a prefix increment operator because the Increment (++) operator is used before the operand (a). Similarly, when we write like <code>a++</code> In our code, it represents a postfix increment operator because the Increment (++) operator is used after the operand (a).</p>
<p>Ok, now you would have understood the meaning of postfix and prefix in unary operators. Now let's understand what does this (++) and (--) symbols do and how the final values are evaluated.</p>
<blockquote>
<p>The final evaluation is not just depended on the unary operator but also on the position it is used. Also always keep in mind that ++ or -- operators only increase or decrease the value with <strong>1</strong> only not less that that nor more than that. But when it will increase or decrease will depends on the position it is beign used.</p>
</blockquote>
<p>Below is the simple code given. Run that in your browser or in your Node environment. Then continue reading the blog to understand the real meaning of it.</p>
<pre><code class="language-javascript">let a = 10;
console.log(++a);
console.log(++a);
console.log(a);
console.log(a++);
console.log(a++);
console.log(a);

let b = 10;
console.log(--b);
console.log(--b);
console.log(b);
console.log(b--);
console.log(b--);
console.log(b);
</code></pre>
<p>Whenever we use the increment operator in the prefix position, it increments the value by 1 instantly of that operand. And when we use the increment operatorin the postfix position, it doesn't increment the value at the very instant, but whenever we use it in the future, then it will add 1 to that operand.</p>
<p>I know, I know, the last line is a little confusing, but bear with me, read the last sentence 2-3 times, and continue reading.</p>
<pre><code class="language-javascript">let a = 10;
// As we are using increment operator in prefix position, it will update the value of a from 10 -&gt; 11 instantly
console.log(++a); // output: ++a = a + 1 = 10 + 1 = 11

// Now as the value of 'a' is updated to 11, from here onward the value of 'a' will be 11 until an unless we update it to something else.
// And now this time as we are using the increment operator but this time in postfix position, it will not update the value at the instant. Instead it will forward that if 'a' is used in the future or not, if yes, it will add on that place
console.log(a++); // output: a++ = a = 11
// From the previous line 'a++'
console.log(a);   // output: a = a + 1 = 11 + 1 = 12
</code></pre>
<p>Below is the visual representation of similar code.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/8d345540-e51c-4cd7-a47c-ca1b0c052975.png" alt="" />

<p>This is how you can visualize the whole process of the unary operator. And in case of the decrement operator, you just have to decrease the value by one, like below.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/2ee9fd44-a997-416e-8f08-5e7eef4d8ba6.png" alt="" />

<p>Hopefully, you have understood the concept of Unary Operator, and to test that, there is a little task for you guys. Do let me know the answer in the comments.</p>
<pre><code class="language-javascript">// Q1. 
let a = 10, b = 20;
const finalValue = ++a + ++b - b-- - a-- + a++ - --b
console.log(finalValue);

// Q2.
for (var i = 10; i &lt; 20; ++i) {
    console.log(i);
    i += 2 // i += 2 =&gt; i = i + 2 =&gt; i = 2 + 2 =&gt; i = 4;
}

// Q3.
for (var i = 10; --i &gt; 0; i--) {
    console.log(i);
}
</code></pre>
<p>Question 1 is a little bit tricky, so I am providing the visual solution to that as well.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/9ea566f6-c3b2-4721-9624-68076a47f55b.png" alt="" />

<h4>Relational Operators</h4>
<p>The next set of operators we have in our bucket list is <strong>Relational Operator.</strong></p>
<p>You would be familiar with this, as it is also taught in school; the operators are <code>&lt;, &gt;, &lt;=, &gt;=, !=, ==</code></p>
<p>But, is javascript we also have <code>===</code> . Now you will ask what the difference is between double equal two and triple equal two. Nothing much, like double equal too is too strict, but triple equal to is very strict, like your maths teacher who cuts your whole marks even if the last line of your solution is wrong.</p>
<p>Whenever you use the double equal sign, JavaScript tries to convert the data into nearly all possible data types (implicit data type conversion) so that both the values can match. Just like your English teacher who sometimes forgives your grammar or spelling mistakes and gives you the full marks.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6507feb8121598e399077e8b/f481baaf-556b-4835-b24b-8e0b9768ecfe.png" alt="" />

<h3>The Golden Rule Most Senior Engineers Follow</h3>
<h3>Use this mental rule:</h3>
<pre><code class="language-plaintext">Always use === and !==
unless you have a very specific reason not to.
</code></pre>
<p>This prevents <strong>JavaScript type coercion chaos</strong>.</p>
<p>Because things like this exist:</p>
<pre><code class="language-plaintext">[] == false   // true
"" == 0       // true
"0" == false  // true
</code></pre>
<p>JavaScript code example for all the Relational Operators.</p>
<pre><code class="language-javascript">const age = 10 == "10";
const marks = 45 === "45";

console.log(age);   // Output: true
console.log(marks); // Output: false


const userAge = 18;

if (userAge === 18) {
  console.log("User is exactly 18");
}

const status = "inactive";

if (status !== "active") {
  console.log("User cannot access dashboard");
}

const score = 90;

if (score &gt; 80) {
  console.log("Excellent performance");
}

const temperature = 10;

if (temperature &lt; 15) {
  console.log("It's cold outside");
}

const age = 18;

if (age &gt;= 18) {
  console.log("Allowed to vote");
}

const itemsInCart = 5;

if (itemsInCart &lt;= 10) {
  console.log("Eligible for small package shipping");
}

// Real world senarios

function canAccessDashboard(user) {

  if (user === null) return false;

  if (user.role !== "admin") return false;

  if (user.loginAttempts &gt;= 5) return false;

  return true;
}
</code></pre>
<h4>Logical Operator</h4>
<p>Let's move to logical operators.</p>
<p>So what exactly are logical operators?</p>
<p>They help us to make logical decisions, like whether we should do this or that.</p>
<p>We have 3 different operators under logical operators:</p>
<ol>
<li><p>And ( &amp;&amp; )</p>
</li>
<li><p>Or ( &amp;&amp; )</p>
</li>
<li><p>Not ( &amp;&amp; )</p>
</li>
</ol>
<p>Let's go inside the code and understand its working.</p>
<h3>1. <code>&amp;&amp;</code> (AND operator)</h3>
<p>Think of <code>&amp;&amp;</code> as <strong>a strict parent</strong>.</p>
<p>Everything must be correct.<br />If <strong>one condition fails</strong>, the whole plan is cancelled.</p>
<h3>Real life example</h3>
<p>You want to go out with friends.</p>
<p>But your mom says:</p>
<pre><code class="language-plaintext">You can go out IF
you finish homework AND clean your room
</code></pre>
<p>So the rule becomes:</p>
<pre><code class="language-plaintext">homeworkDone &amp;&amp; roomClean
</code></pre>
<p>Code version:</p>
<pre><code class="language-javascript">const homeworkDone = true
const roomClean = false

if (homeworkDone &amp;&amp; roomClean) {
  console.log("You can go outside")
} else {
  console.log("Stay at home and suffer")
}
</code></pre>
<p>Since the room is not clean:</p>
<pre><code class="language-plaintext">true &amp;&amp; false → false
</code></pre>
<p>Result:</p>
<pre><code class="language-plaintext">Stay at home
</code></pre>
<p>The AND operator is basically saying:</p>
<blockquote>
<p>“No shortcuts. Everything must be done.”</p>
</blockquote>
<p>Example from real apps:</p>
<pre><code class="language-javascript">if (userLoggedIn &amp;&amp; userRole === "admin") {
  console.log("Access granted")
}
</code></pre>
<p>Meaning:</p>
<pre><code class="language-javascript">User must be logged in
AND
User must be admin
</code></pre>
<p>Otherwise:</p>
<pre><code class="language-plaintext">Security guard says: "Nice try."
</code></pre>
<hr />
<h3>2. <code>||</code> (OR operator)</h3>
<p>This one behaves like a <strong>lazy friend</strong>. Only <strong>one condition needs to be true</strong>.</p>
<h3>Real life example</h3>
<p>You’re ordering food.</p>
<p>Your brain says:</p>
<pre><code class="language-plaintext">If pizza OR burger is available, I will eat.
</code></pre>
<p>Expression:</p>
<pre><code class="language-plaintext">pizzaAvailable || burgerAvailable
</code></pre>
<p>Code:</p>
<pre><code class="language-javascript">const pizzaAvailable = false
const burgerAvailable = true

if (pizzaAvailable || burgerAvailable) {
  console.log("Food secured. Happiness restored.")
}
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">Food secured. Happiness restored.
</code></pre>
<p>Even though pizza is unavailable, burger saves the day.</p>
<p>OR operator basically says:</p>
<blockquote>
<p>“I’m not picky. Just give me something.”</p>
</blockquote>
<hr />
<h3>3. <code>!</code> (NOT operator)</h3>
<p>This is the <strong>opposite machine</strong>.</p>
<p>It flips truth like a light switch.</p>
<h3>Real-life example</h3>
<p>Your brain is checking Monday morning motivation.</p>
<pre><code class="language-plaintext">motivated = false
</code></pre>
<p>Then someone asks:</p>
<pre><code class="language-plaintext">Are you NOT motivated?
</code></pre>
<p>Code:</p>
<pre><code class="language-javascript">const motivated = false

if (!motivated) {
  console.log("Back to sleep")
}
</code></pre>
<p><code>!</code> flips the value:</p>
<pre><code class="language-javascript">!false → true
</code></pre>
<p>So the output is:</p>
<pre><code class="language-plaintext">Back to sleep
</code></pre>
<p>NOT operator basically says:</p>
<blockquote>
<p>“Whatever this was… do the opposite.”</p>
</blockquote>
<h1><strong>Assignments</strong></h1>
<h3>Guess the Output</h3>
<pre><code class="language-javascript">const a = 10;
const b = "10";
const c = 20;

console.log(a == b);
console.log(a === b);
console.log(a != b);
console.log(c &gt; a);
console.log(a &lt; c);
console.log(a &gt;= 10);
console.log(c &lt;= 15);
</code></pre>
<h3>Fix the Logic</h3>
<pre><code class="language-javascript">const marks = "40";

if (marks == 40) {
    console.log("Student scored exactly 40");
}

if (marks &gt;= 40) {
    console.log("Student passed");
}

if (marks &lt; 40) {
    console.log("Student failed");
}

if (marks != 100) {
    console.log("Student did not get full marks");
}
</code></pre>
]]></content:encoded></item><item><title><![CDATA[cURL Explained: From Basic Server Requests to API Calls]]></title><description><![CDATA[Introduction
cURL (Client URL) is a utility tool built on top of multiple underlying libraries, including libcurl, libcurl-easy, libcurl-share, and more. In this article, we will learn how to use this tool throughout the Software Development journey....]]></description><link>https://blog.baruntiwary.dev/curl-explained-from-basic-server-requests-to-api-calls</link><guid isPermaLink="true">https://blog.baruntiwary.dev/curl-explained-from-basic-server-requests-to-api-calls</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[curl]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Wed, 28 Jan 2026 00:09:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769558857710/793cb55e-5a94-40e0-82c3-c44ef78e60b9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>cURL (Client URL) is a utility tool built on top of multiple underlying libraries, including libcurl, libcurl-easy, libcurl-share, and more. In this article, we will learn how to use this tool throughout the Software Development journey.</p>
<p>But before that lets understand about the server.</p>
<p>What is a server?</p>
<p>It is just like your personal laptop or computer that serves something. It could be anything from files to web pages. Simple right?</p>
<p>So, what does it look like?</p>
<p>Though there is no face to it, if you want, you can buy your own server as well for just a few hundred rupees.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769554162407/1e24aeaa-7477-4422-9eb8-473cf13cf18f.png" alt /></p>
<p>Here I own 2 different servers.</p>
<ul>
<li><p>First server is running the famous n8n automation tool for my social media automation.</p>
</li>
<li><p>And the other server serves the website I own.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769554297357/62a60417-923e-4e31-9a4f-80141e831e1f.png" alt /></p>
<p>This is what a server looks like. Yes, it is the os without any graphics, mostly.</p>
<p>Now, in my second server, I have some web apps. To test those web apps or to interact with them, we can use terminals. But what if we just need to check if the website is up and running, or we need to create some automation that checks every hour if it is up or not?</p>
<p>So, this can be done using cURL.</p>
<p>Now, what exactly is cURL?</p>
<p>It is the tool that helps us to transfer data from or to the server using a URL. And as we know, there are multiple ways we can connect to a server like http, ftp, mqtt and other; cURL supports most of them. Which means we can connect to the server via most of the protocols and transfer or download data through it.</p>
<h1 id="heading-first-command">First command.</h1>
<p>Now let's make our very first curl request to a server.</p>
<p><code>curl protocol://resource-path</code></p>
<p>The above is the very basic way of using the cURL command, where we first tell the terminal to use <code>curl</code> the tool, and then we specify from where to get the resource.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769555838866/9ec346ea-ea47-4046-825b-0636a376f839.png" alt /></p>
<p>So what actually happens?</p>
<ul>
<li><p>The <code>curl</code> created a request with the resource information</p>
</li>
<li><p>Made a request to that resource based on the protocol and flags passed</p>
</li>
<li><p>Collect the response and print it into the <code>STDIN</code> or in simple words, in the terminal.</p>
</li>
</ul>
<p>Now we got to know about request and response. So what are these now?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769556625142/85c52739-a6fa-4450-8e79-77b735e2af3d.png" alt /></p>
<p>As you can see above, when you request any website in your browser, it requests that domain just like we did it using <code>curl</code>. When we open that request, we see there is something called <code>Response Headers</code> and <code>Request Headers</code>.</p>
<p>So, in requests, we define multiple things like.</p>
<ul>
<li><p>methods</p>
</li>
<li><p>path</p>
</li>
<li><p>root domain</p>
</li>
<li><p>content-type</p>
</li>
<li><p>protocols</p>
</li>
</ul>
<p>and many more things, though, which server understands what we are trying to access.</p>
<p>And just like the request server create response with the same information, in addition with extra information that we request to the server.</p>
<h1 id="heading-api-calling">API calling.</h1>
<p>Now lets move on to how to make api request while testing APIs or for doing reverse engineering.</p>
<p>Before moving ahead, we first need to understand some nuances of the API, like</p>
<ul>
<li><p>Methods : There are multiple methods that we can use to make an API request</p>
<ol>
<li><p>GET → It is used to request some resource from the server</p>
</li>
<li><p>POST → It is used to create a new resource in the DB through the server.</p>
</li>
<li><p>PUT → It is used to update the existing resources.</p>
</li>
</ol>
</li>
<li><p>Content-Type : What type of content are we requesting from the server, like JSON, form data, or what?</p>
</li>
<li><p>Authorization : It is used to verify our authenticity, which means we tell the server look, I have access to this specific API, here is the key (Access Token). Check this and let me access the resource.</p>
</li>
</ul>
<p>Now lets make some API requests to real servers and see what happens.</p>
<h3 id="heading-getting-joke-from-api">Getting Joke from API</h3>
<p><code>curl -X GET -H “Accept: application/json” https://icanhazdadoke.com</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769557935981/53f060b3-76a3-4d96-8665-233b8c2ea68e.png" alt /></p>
<p>As you can see, we have successfully made our 2nd API request using curl.</p>
<p><strong>Explanation</strong></p>
<p>-X GET → X flag defines which method we want to use, like GET, POST, PUT, DELETE, or what.</p>
<p>-H “Accept: application/json” → It defines what type of content we are expecting.</p>
<p>And finally, we added the actual API <code>https://icanhazdadjoke.com</code> where we need to make an API request to get the response.</p>
<p>Let me know if you want a more detailed article around cURL.</p>
]]></content:encoded></item><item><title><![CDATA[Barun's Experience: Learning Networking Devices While Setting Up a New Office]]></title><description><![CDATA[NOTE: There is no sponsherhip from any company for this blog.

In this article, with the real world analogy, we are going to learn about how the internet works and the key hardware and software components which helps us to access the internet.
Analog...]]></description><link>https://blog.baruntiwary.dev/baruns-experience-learning-networking-devices-while-setting-up-a-new-office</link><guid isPermaLink="true">https://blog.baruntiwary.dev/baruns-experience-learning-networking-devices-while-setting-up-a-new-office</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[networking]]></category><category><![CDATA[routing]]></category><category><![CDATA[SWITCH]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Thu, 22 Jan 2026 14:28:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769091854023/abc015c1-a1c9-4c97-8016-b24df44e84fb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>NOTE: There is no sponsherhip from any company for this blog.</p>
</blockquote>
<p>In this article, with the real world analogy, we are going to learn about how the internet works and the key hardware and software components which helps us to access the internet.</p>
<h2 id="heading-analogy">Analogy</h2>
<p>Barun is renting the new office for his new business. He runs a software development agency named <a target="_blank" href="https://rfautomation.in">RF-Automation</a>, where he helps businesses to automate their time-consuming operational tasks and build the software for them. Till now, he was working alone from his home, now he wants to rent the office and hire 10-20 employees to expand his agency.</p>
<p>Now, Barun has hired 15 employes mix of Software Developer, Project Manager, and other roles. Also, he has rented an office near HSR Layout in Bangalore. He has also arranged 10 computers, a few printers, and other office furniture to make it look like an agency. Now he need the access to the internet. But currently he does not have any. So, he opened the Airtel thanks app and applied to get access to the high-speed internet available.</p>
<p>On the same evening, the engineer from Airtel arrives at the office location to install Airtel X Stream Wi-Fi. First, he finds the available spot on the nearest Airtel Fiber (Fiber Access Terminal) Box so that he can connect the Airtel Modem (ZYXEL Modem + Router) to it and give him access to the internet.</p>
<blockquote>
<p>FAT Box → Fiber Access Terminal Box is the main devices installed in the apartments, flats and other premises for distributing the internet from the main fiber cables to the multiple individual subscriber.</p>
<p>Airtel uses modem of ZYXEL company which build networking related solutions.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768937129319/55318767-beb0-420e-a82e-94a5a709f45d.jpeg" alt /></p>
<p>Once the engineer finds the available spot near his premise inside the fat box, then he add the new fiber optic cable into that spot, which is connected to the coaxial cable, which will then go to inside the office, where the engineer will install the Airtel Wi-Fi or modem.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768938060796/41976ee2-0402-49a3-9763-1a13b61896e5.png" alt /></p>
<p>The black coaxial cable you can see in the above image is the cable that will go to the home modem, as shown in the image. Finally, the engineer joined the black coaxial cable with the fiber optic cable, and it is connected to the ZYXEL Modem. Now, from this modem, Barun can use the internet in his whole office wirelessly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768938446432/17c5a6ec-09bd-4378-93bd-7707ce6b48d8.jpeg" alt /></p>
<p>Now, still there is still an issue; he has 10 computers and a few printers. A few of the computers have the Wi-Fi capabilities, but a few computers and printers can’t use the internet through a modem as they don’t have wifi capabilites in them. Barun can’t spend more money on buying wifi connector, so he decided to add a switch. He bought a switch from D-Link (DES 1008A), which will connect the modem to the computers and printer, which doesn’t have wifi capabilites.</p>
<p>Now, Barun can run the agency smoothly.</p>
<h2 id="heading-technical-knowledge">Technical Knowledge</h2>
<h3 id="heading-hub">Hub</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768945531498/71f4d40a-2cbf-443c-adaa-1de6785427a9.jpeg" alt class="image--center mx-auto" /></p>
<p>Barun has not used Hub as he knows how dumb hub it is. Though it is one of the early devices from the early internet era, which helps to connect multiple computers in the LAN (Local Area Network → your home network, which consists of your mobile phones, printers, laptop, PCs, etc), it is still not a relevant network device to use. And still some of the broadcasting features of the Hub is used in your home wifi router.</p>
<p>A hub is a dumb device that broadcasts data from one device to all the other devices connected to the hub, as shown in the image below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768950958241/56a9dcb5-f94f-4569-afe1-f493d39462b5.png" alt /></p>
<ul>
<li><p>Hub is usefull to connect multiple device in the local area to share information.</p>
</li>
<li><p>Hub broadcasts data from device A to all the other devices connected to it. The devices recieves the data and compare its mac address (unique id for each devices world wide) to the mac address in the data packet (recivers mac address). If both mac address matches, the device consume the data; otherwise, it drops the data packet.</p>
</li>
<li><p>Because of its broadcasting nature, it has several drawbacks like when device A sends the data to device B, and at the same time, if device C sends the data to device D, there is a collision in the hub. As the data of device C and device A travel at the same time, they will collide, and the data gets lost. Becuase of this, it is also called SIngle Collision Domain.</p>
</li>
</ul>
<h3 id="heading-switch">Switch</h3>
<p>It is the smartest alternative of hub. It knows which device is connected to which port. And it helps devices to connect locally and form a topology like bus, start, mesh, and others.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769007948344/22402211-11fb-440a-8fda-d0fa3f6abb8f.jpeg" alt class="image--center mx-auto" /></p>
<ul>
<li><p>It uses the computers/devices MAC (Media Access Control) Address to identify each devices uniquely and route the data packets to the specific device.</p>
</li>
<li><p>Switch, when installed fresh or reset, doesn’t know the MAC Address of any devices connected to it. When the device sends the first data from device A to device B, switch first broadcasts the message and sees who receives it, and stores that information into a CAM (Content Addressable Memory) table. Likewise, it learns the MAC address of all the connected devices and the port they are connected to.</p>
</li>
<li><p>CAM is the high-speed hardware component built inside the switch that helps it to maintain records of MAC and its respective port. It also helps to forward Ethernet frames near instantly using hardware-based lookup.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769075979245/572a8f39-f371-4017-b22e-4cd326e6dbce.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p>A switch is only used inside the LAN (Local Area Network), unlike a router, which is used to connect the LAN to the internet.</p>
</blockquote>
<h3 id="heading-router-amp-modem">Router &amp; Modem</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769076671981/92c6ca39-a01c-41a7-80d2-f9499361a98d.webp" alt /></p>
<p>Sometimes people confuse a router and a modem and use this word interchangeably. Because these days the ISP (Internet Service Providers) like Airtel, JIO and other provided both in the same device. But both of these have different working mechanisms.</p>
<p>As shown in the image above, there is the Modem in the left side and a router on the right side. They are both identical right, just the router has one antenna (In some case you would see more than one). So what’s the difference?</p>
<h4 id="heading-modem-modulator-de-modulator">MoDem (Modulator De-Modulator)</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769078838358/770006d6-a6b1-4a9a-a961-73dce78de780.png" alt class="image--center mx-auto" /></p>
<p>As the name suggest it's the guy who is actually responsible for converting the analog signal coming from the ISP’s coaxial cable (or through any other medium like DSL, Satellite, or others) into the digital signal that can be consumed by your LAN devices.</p>
<p>As you can see in the image above modem can only be used with one device. It cannot be connected to multiple devices because its primary use is to convert the analog signals to digital signals, which computers and other devices can understand. This is the reason why we use a router on top of the Modem in the LAN to get the digital signal (Internet) into the router and then route the data packets to multiple devices connected to it respectively.</p>
<h4 id="heading-router">Router</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769089531226/a7a75b80-3541-443d-a0d3-a53e98e59934.png" alt class="image--center mx-auto" /></p>
<p>Again, as the name suggests, it routes the incoming data from the modem to the devices in the LAN. A router can consist of a wireless Access Point and a wired (RJ45) interface.</p>
<p>The router's main purpose is to distribute the data packets between your networks and the outside world (without internet, we can also utilize the router to share data between local devices). Just like switches, a router is also a smart network device, even better than a switch.</p>
<p>Nowadays, routers come with built-in switches and a basic firewall as well. A router also has the functionality of assigning an IP address to the devices in the network, so that they can be identified easily for sharing data.</p>
<h3 id="heading-firewall">Firewall</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769090814354/eca665d1-7709-4573-90d6-bcec6e0d3f52.webp" alt class="image--center mx-auto" /></p>
<p>A firewall is a network security device that monitors incoming and outgoing traffic based on configurable security rules (rules can be changed accordingly). It helps us to protect the internal networks from the outside world (untrusted networks/Internet) or maintain a barrier between VLANs (Virtual Local Area Network).</p>
<blockquote>
<p>Firewalls can be hardware or software both.</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Basic Git Commands: Part 1]]></title><description><![CDATA[Today, we will discuss the 6 most important Git commands you should know, whether you are a software developer, frontend engineer, backend developer, or even if you work in DevOps and cloud.

If you are new to Git then first read this internal of git...]]></description><link>https://blog.baruntiwary.dev/basic-git-commands-part-1</link><guid isPermaLink="true">https://blog.baruntiwary.dev/basic-git-commands-part-1</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[Gitcommands]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Thu, 15 Jan 2026 19:43:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768506158406/5183c263-dbbb-4929-9a4e-8d5f6a450256.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Today, we will discuss the 6 most important <strong>Git commands</strong> you should know, whether you are a software developer, frontend engineer, backend developer, or even if you work in DevOps and cloud.</p>
<blockquote>
<p>If you are new to Git then first read <a target="_blank" href="https://blog.baruntiwary.dev/a-guide-to-gits-core-components-and-how-they-function">this internal of git</a> article to have a basic understanding of Git. This article will be divided into three parts. In each part, we will discuss two categories of commands.</p>
</blockquote>
<h1 id="heading-6-categories-of-basic-git-commands">6 Categories of basic Git commands.</h1>
<ol>
<li><p>Project Setup</p>
<ul>
<li><p>git clone</p>
</li>
<li><p>git init</p>
</li>
</ul>
</li>
<li><p>Daily Workflow</p>
<ul>
<li><p>git status</p>
</li>
<li><p>git add</p>
</li>
<li><p>git commit</p>
</li>
</ul>
</li>
<li><p>Branching &amp; Navigating</p>
<ul>
<li><p>git branch</p>
</li>
<li><p>git checkout</p>
</li>
<li><p>git merge</p>
</li>
</ul>
</li>
<li><p>Sharing &amp; Updating</p>
<ul>
<li><p>git pull</p>
</li>
<li><p>git push</p>
</li>
<li><p>git fetch</p>
</li>
</ul>
</li>
<li><p>Inspecting &amp; Comparing</p>
<ul>
<li><p>git log</p>
</li>
<li><p>git diff</p>
</li>
</ul>
</li>
<li><p>Handling Interruptions &amp; Mistakes</p>
<ul>
<li><p>git stash</p>
</li>
<li><p>git reset</p>
</li>
<li><p>git revert</p>
</li>
</ul>
</li>
</ol>
<p>Let’s dive deep into each of these commands.</p>
<h2 id="heading-project-setup">Project Setup.</h2>
<h3 id="heading-git-init"><strong>git init</strong></h3>
<blockquote>
<p>If you do not have git installed in your computer, do it from <a target="_blank" href="https://medium.com/@maksymrudnyi/how-to-install-git-on-windows-10-git-installation-in-windows-tutorial-55313c5a818a">this article.</a></p>
</blockquote>
<p>This category provides help to set up your new Git project locally or clone any other project from GitHub.</p>
<p>First, learn about how to create a local git project.</p>
<p>To do so, we will use <code>git init</code> a command, but before that, first set up the project with a name <code>git-commands</code></p>
<pre><code class="lang-bash">mkdir git-commands
<span class="hljs-built_in">cd</span> git-commands

<span class="hljs-comment"># Once folder is created and we are inside this folder we can initialize a git repository here.</span>
git init

<span class="hljs-comment"># Git is the command line tool and init is the flag which tells the git to initialize</span>
<span class="hljs-comment"># the new git project in the curent folder. This command is responsible for creating</span>
<span class="hljs-comment"># .git folder inside the current folder.</span>
</code></pre>
<p>Once we are done with creating a new git project locally, we can run <code>git status</code> the command to see if it is actually done or not.</p>
<blockquote>
<p><code>git status</code> helps to check the current project status. We will look into this in this article.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768439721618/6c91a6c8-900f-4d55-a6b3-33423ede5c86.png" alt /></p>
<h3 id="heading-git-clone">git clone</h3>
<p>If you want to clone another GitHub repository, there are a few more commands and steps to follow. However, that is not covered in this article. We might discuss it later, so feel free to continue. If you run into any issues, please let me know in the comments or reach out to me on Twitter. I'll be happy to help you.</p>
<p>So, how to clone a project?</p>
<p>First, grab the URL of the HTTPS URL of the GitHub project, and then we just need to use a simple git command as follows.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768441347859/2d1f7df3-0589-4e8a-b902-a5ac70e4f677.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash"><span class="hljs-comment"># git clone url_of_the_git_project_to_clone</span>
git <span class="hljs-built_in">clone</span> https://github.com/Barun355/chess-frontend
</code></pre>
<p>Once done, you will see the <code>chess-frontend</code> codebase is cloned into your current folder.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768441443489/3baa1edc-a2cf-47e2-96db-2e6aee8ba023.png" alt class="image--center mx-auto" /></p>
<p>After cloning the project, you can go into the project, contribute to it, and then push the changes by raising PRs and all.</p>
<h2 id="heading-daily-workflow">Daily Workflow</h2>
<p>We explored the essential commands you should know before moving forward. Now, let's look at another simple example to understand the basic commands we will use about 60-70% of the time.</p>
<p>So, let's take an example from <a target="_blank" href="https://blog.baruntiwary.dev/a-guide-to-gits-core-components-and-how-they-function">the last article</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768441928253/9b6f5a9d-530a-416e-97a2-1ef42123e6c8.png" alt class="image--center mx-auto" /></p>
<p>Here we already have a project set up named <code>git-internal</code> where we have done some of the work.</p>
<h3 id="heading-git-status">git status</h3>
<p>We have already seen this command. It helps us display the current state of our working directory and staging area. It also shows us the current tree inside the working directory.</p>
<p>It is primarily used for:</p>
<ul>
<li><p>Identify changes: Show modified, new, or deleted files.</p>
</li>
<li><p>Check staging area: Determine which changesareready to be committed</p>
</li>
<li><p>Verify working tree: Confirm if your project is in a clean state (i.e., nothing to commit).</p>
</li>
</ul>
<p>Common options</p>
<ul>
<li><p><code>git status -s</code> (Short format) : Provides a more compact, summarized output.</p>
</li>
<li><p><code>git status -b</code> : Displays branch tracking information</p>
</li>
<li><p><code>git status -v</code> : Shows verbose details, including the textual changes of uncommitted files</p>
</li>
</ul>
<p><strong>Technical Explanation</strong></p>
<p>The status options show 3 different things in the output for a simple project:</p>
<ol>
<li><p>Difference between the index file (staging area) and the current HEAD Commit (Latest Commit).</p>
</li>
<li><p>Difference between the working tree and the index file (staging area)</p>
</li>
<li><p>And finally, files and folders that are not being tracked by git yet. This excludes all the files and folders that are listed in <code>.gitignore</code> file.</p>
</li>
</ol>
<h3 id="heading-git-add">git add</h3>
<p>This command allows you to move changes in files or newly created files that are not yet tracked by Git to the index (staging area). Here, all updates are stored before being included in the next commit.</p>
<p>To showcase the <code>add</code> option, we will first create a <code>greet.js</code> and <code>loop.js</code> file, and we will see the most basic way of using this option.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># create greet.js file</span>
touch greet.js loop.js
</code></pre>
<pre><code class="lang-javascript"># greet.js
<span class="hljs-keyword">const</span> greet = <span class="hljs-string">`Hello Barun Tiwary`</span>;
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${greet}</span>`</span>);
</code></pre>
<pre><code class="lang-javascript"><span class="hljs-comment">// loop.js</span>
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">10</span>; i++){
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Current value of i is <span class="hljs-subst">${i}</span>`</span>);
}
</code></pre>
<p>Now, as we have created all the required files, I will demonstrate the most basic way of using <code>add</code> option.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># git add filename</span>
git add greet.js
git add loop.js
</code></pre>
<p>After running the code above, we have moved our newly created untracked files into the index (staging area). Although we did this one by one, it's not practical if we have hundreds or thousands of files to track. In that case, we can use the dot (.) option.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># git add .</span>
<span class="hljs-comment"># (.) represents all the files exluding files matching regex in the .gitignore file</span>
git add .
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768502934359/c6e50a47-1a32-4465-8a50-0b2bdf22789f.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p>Note: Whenever we make changes to a file, create a new file, or delete an existing file in a Git-initialized project, we need to run the add command for all those changes to track them.</p>
</blockquote>
<p><strong>git commit</strong></p>
<p>Now, let's explore the most important Git options that actually store the code's history. First, we will look at the basic commands, and then we will explore the optional flags.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># git commt -m "write a meaningful message to store with the commit history."</span>
git commit -m <span class="hljs-string">"Added greet and loop js files"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768503780909/886b2099-8bf5-4fe7-ac20-40008fc8f27b.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>commit : The options to commit the changes from the index (staging) area.</p>
</li>
<li><p>-m “…” : This allows us to write the commit message directly while executing the commit command.</p>
</li>
</ul>
<p>If you want, you can skip the <code>-m</code> flag. Doing so will open the Vim editor by default, where you can add the commit message and then save the changes. We are using the <code>-m</code> option because it is convenient.</p>
<p>Okay, so far we have covered two categories of basic Git commands, and we will cover the rest in upcoming articles.</p>
]]></content:encoded></item><item><title><![CDATA[A Guide to Git's Core Components and How They Function]]></title><description><![CDATA[In the previous article, we explored why Git is essential in modern development. Today, we are going to learn about the working of VCS and, more specifically, Git Internals.

Open your favourite terminal as this article is going to be full of pratica...]]></description><link>https://blog.baruntiwary.dev/a-guide-to-gits-core-components-and-how-they-function</link><guid isPermaLink="true">https://blog.baruntiwary.dev/a-guide-to-gits-core-components-and-how-they-function</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[Git-Internals]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Wed, 14 Jan 2026 21:28:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768426003324/0590176a-795c-44f5-abfe-8af6d1298652.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the previous <a target="_blank" href="http://blog.baruntiwary.dev/why-the-recipe-reveal-team-opted-for-a-version-control-system-cmjsf9i3y000002jo7b38a607">article</a>, we explored why Git is essential in modern development. Today, we are going to learn about the working of VCS and, more specifically, Git Internals.</p>
<blockquote>
<p>Open your favourite terminal as this article is going to be full of praticals.</p>
</blockquote>
<p>To understand the working of Git, we will create a project named <strong>git-internal</strong> using the command given below.</p>
<p><code>mkdir git-internal</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767184792443/a8329178-d830-4e34-8545-48bbc0ab2bf5.png" alt /></p>
<p>Then we will go inside the project folder using the <code>cd git-internal</code> command</p>
<p>Once the project folder is set up, we are ready to understand the internal working of git. Before that, we are going to build the mental model for the problem of code tracking, resonate with its solution, and then we will go into the jargon of GIT.</p>
<p>Let's suppose we are building a product that tells us the weather information about the city we asked for. For that, we definitely need a code in a file that we can run to get our desired output. And for this article, we are going to use JavaScript as the programming language to build this software.</p>
<p>So, we are going to create a file named <strong>index.js</strong> <code>vim index.js</code> I am using <strong>Vim</strong> as the terminal editor; feel free to use any code editor for this project. And as soon as we create the index file, I guess we should track it that some file has been created in the git-internal folder, right? But how? Let’s leave it for now and write a simple JavaScript code, then run the code using the command `node index.js`.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767187149531/ab792072-e669-40e9-996f-71a4592d8531.png" alt /></p>
<p>We should see the simple output in the terminal saying “Weather Report”.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767187268754/b4f7a1b1-5417-4bd5-9d1f-e045672b7433.png" alt /></p>
<p>But wait… a minute, where is the code to find the weather report of a given city? Don’t worry, at the end of the article, you will have one with you.</p>
<p>Till now, what has happened?</p>
<ol>
<li><p>We created a file named index.js</p>
</li>
<li><p>We have written a simple console log code in that file</p>
</li>
</ol>
<p>Simple right?</p>
<p>We should have tracked these 2 things and such other activities inside the folder <code>git-internal</code> . So, should we store these changes/activities in the database or somewhere but where?</p>
<p>Let’s suppose we store this in a database, at 03sec, 6:59 pm, 31st Dec 2025, a file is created inside <code>git-internal</code> a folder. At 30sec, 6:59 pm, 31st Dec 2025, some code is added. We are tracking activities, which include file creation and any changes within the file, such as adding, deleting, or updating characters (spaces, new lines, or new characters). But what about codes? How are we going to track at what time exactly what code changes? In our case, we are tracking every change in any character, right?</p>
<p>So, it can be a very comput-intensive task, and also maintaining the history of code changes is also very difficult, right? And storing, reading, updating, and deleting activities can trigger way more database calls, which can break the database. And yes, there are a lot of optimised databases available for high-frequency operations, but it doesn’t mean that if something exists, we can use it anywhere. Using those databases can be expensive and also not make any sense in this.</p>
<p>So what is the solution then?….</p>
<p>Fine, no problem, we can’t perform high-frequency operations with the database for just tracking the code changes, but what if we track operations/changes in a block? I mean, we make some changes, like create new files, add a bunch of code/features, update the existing code for improvement, and other things we want to do. Then once we are done with our changes, we can store this update in our database at once, right?</p>
<p>Fine, we got a solution, but still we have to make queries to databases via api calls. And if our network is not stable or for some reason we are not able to connect to the database, then what? Though we have solved the problem of tracking a code. Which is <code>create new project</code> → <code>make changes</code> → <code>track changes</code> → <code>store it into db</code> → <code>update the code</code> → <code>track changes</code> → <code>store it into db</code> → and continue in the loop. But what if the database is not available?</p>
<p>One thing we can do is to store all the tracked files, updates, and changes in a file or folder inside the same project root folder. Can we do that?</p>
<p>Why not? If we can store these things in a database, we can also store them in files. Awesome, so we have almost solved the problems with the first principal and got the way git operates internally.</p>
<p>BUT WAIT!!!!….</p>
<p>So far, whatever we understood didn’t include any technical words or jargon that Git uses. So, let’s dive into it and relate whatever we understand so far to Git's internal working.</p>
<h1 id="heading-git-jargon">Git jargon</h1>
<p>Now it’s time to create a git repository inside the folder we created <code>git-internal</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767647252040/3ed8dcac-cc8d-4642-9bcf-0d7373b98786.png" alt /></p>
<p>Before creating a git repository using <code>git init</code> In the command inside the root folder, there is only 1 file. And after initializing git in the folder, it still has that file only, nothing else. As we have discussed earlier, there should be some folder or files that git will use to track the code.</p>
<p>Yes, it creates a folder, but it is hidden because git does not want to expose these folders by default to anyone and track the changes anonymously. So, we can’t see those changes?…</p>
<p>Not really, we can still see those, though the folder is hidden, but we can still access it using the command <code>ls -al</code> or <code>ll</code> in Linux terminal (My system is Ubuntu 22.x version</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767647617977/0113ea8b-1403-4890-94c7-64104dae74cf.png" alt class="image--center mx-auto" /></p>
<p>You can also see the success message that git shows <code>Initialized my Git repository in /folder/path/.git</code> . And after running the command <code>ls -la</code> It not only displays the files and folders in the current directory, including hidden files, but also provides additional details for each file and folder.</p>
<blockquote>
<p>Hidden files and folders start with dot (.), just like git have one <code>.git</code></p>
</blockquote>
<p>If we go into this folder and run <code>ls</code> We will see a bunch of files and folders.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767647912819/1608a34a-7622-4c39-8ce6-52c30c2ed9ec.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>branches (folder)</p>
<p> This is the folder that contains all the branch info you create in the repositories.</p>
</li>
<li><p>config (file)</p>
<p> This file contains the local, repository-specific configuration that controls how git operates in that specific repository. This configuration overwrites any global or system-wide configuration for the project.</p>
<p> It stores a bunch of information like:</p>
<ul>
<li><p>Remote repository URL</p>
</li>
<li><p>Branch-specific configuration.</p>
</li>
<li><p>User info. (Though the userinfo is globally set in git. But it can also be different for any specific repository/project)</p>
</li>
</ul>
</li>
<li><p>description (file)</p>
<p> It just contains a single line statement <code>Unnamed repository; edit this file 'description' to name the repository</code> . However, it typically contains a description of the project in plain text.</p>
</li>
<li><p>HEAD (file)</p>
<p> This file contains the reference to the latest active branch, which itself references the actual commit hash. (Don’t worry, we are going to see all about hashes, object types, and all).</p>
</li>
<li><p>hooks (folder)</p>
<p> This folder contains some sample scripts, or we can also create our own scripts that can run in the different stages of git. Like just after staging the changes, committing the current stage, before merging branches, or before pushing the changes to the remote repository.</p>
</li>
<li><p>info (folder)</p>
<p> This folder contains local and private information about the repository, which is not intended to be shared with any other repositories or developers. The main file inside this folder is <code>exclude</code> which acts as the private <code>gitignore</code> file, but unlike the <code>gitignore</code> Files are private to the local repository and are not shared on GitHub.</p>
</li>
<li><p>objects (folder)</p>
<p> It is the main culprit inside <code>.git</code> . A folder that contains all the changes inside, which are tracked. There are 3 types of objects in git.</p>
<ul>
<li><p>Commit</p>
</li>
<li><p>Tree</p>
</li>
<li><p>Blob</p>
</li>
</ul>
</li>
</ol>
<p>    We are going to discuss all three objects in detail, with how git stores them.</p>
<ol start="8">
<li><p>refs (folder)</p>
<p> <code>objects</code> folders store the actual tracked files and their SHA-1 hash, which is not easy to remember. Every time we need to access the file history, we need to access it using the SHA-1 hash of the respective files or folders. So, to store the easy and memorable names of these SHA-1 hashes, we use the refs folder.<br /> It contains:</p>
<ul>
<li><p>heads</p>
</li>
<li><p>tags</p>
</li>
</ul>
</li>
</ol>
<p>Now, we have a decent understanding of what git has inside its folder. Now let’s go through the different states of git to get an understanding of how git flow works, then we will be back to understand Objects (folder) and refs (folder), which we need to understand only for now.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767878399850/fef2d8bf-e40b-44c6-bf96-c6b9ac92e60f.png" alt="The lifecycle of the status of your files." /></p>
<p>The image above is taken from the official <a target="_blank" href="https://git-scm.com/book/pt-pt/v2/No%C3%A7%C3%B5es-B%C3%A1sicas-do-Git-Recording-Changes-to-the-Repository">git page</a>.</p>
<p>There are a total of 4 states in Git (If we are just using git locally).</p>
<ol>
<li><p>Untracked</p>
</li>
<li><p>Unmodified</p>
</li>
<li><p>Modified</p>
</li>
<li><p>Staged</p>
</li>
</ol>
<p>There is one more state called <strong>Commit</strong>.</p>
<p>When we initialize a git repository in a folder, it is called <code>working directory</code> in Git terms. This contains all the Untracked files initially.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767880200730/9ed2867c-7f6f-44be-b208-4d1609ee771e.png" alt /></p>
<h4 id="heading-untracked-state">Untracked State</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767880750810/72c8c917-b46e-4e82-8de9-771640abb085.png" alt class="image--center mx-auto" /></p>
<p>This is the state of files that are not tracked by git yet. Which means git is not aware of these files. We need to tell git explicitly to track this file. So, as in the Git state image shown. We can change the file’s state from Untracked to Staged so that it can get tracked through Git. But before that, we can add some working code so that we have something to work upon.</p>
<p>So, now we have hard-coded the different city weather reports in <code>index.js</code> file.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// index.js</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Weather Report Applications"</span>);

<span class="hljs-keyword">const</span> weather_report = {
    <span class="hljs-string">"jsr"</span>: {
        <span class="hljs-string">"city"</span>: <span class="hljs-string">"Jamshedpur"</span>,
        <span class="hljs-string">"temperature"</span>: <span class="hljs-string">"30°C"</span>,
        <span class="hljs-string">"condition"</span>: <span class="hljs-string">"Sunny"</span>
    },
    <span class="hljs-string">"del"</span>: {
        <span class="hljs-string">"city"</span>: <span class="hljs-string">"Delhi"</span>,
        <span class="hljs-string">"temperature"</span>: <span class="hljs-string">"35°C"</span>,
        <span class="hljs-string">"condition"</span>: <span class="hljs-string">"Hot"</span>
    },
    <span class="hljs-string">"mum"</span>: {
        <span class="hljs-string">"city"</span>: <span class="hljs-string">"Mumbai"</span>,
        <span class="hljs-string">"temperature"</span>: <span class="hljs-string">"28°C"</span>,
        <span class="hljs-string">"condition"</span>: <span class="hljs-string">"Humid"</span>
    }
}
</code></pre>
<p>Still, the <code>index.js</code> file is untracked. Let’s move it into the staging area or state with the below command.</p>
<p><code>git add index.js</code></p>
<blockquote>
<p>Instead of manually adding the file in the command <code>git add file1 file2 ..</code> we can add all the files at once using <code>git add .</code> , it will add all the files in the current folder in staged area.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767881145336/e98cce5e-2ade-4ec5-9559-9b0d42197c3a.png" alt class="image--center mx-auto" /></p>
<p>Now, as you can see. Our <code>index.js</code> file is moved to the staging area, and the status of the index.js file is changed to <code>A</code> in the VS Code GitHub sidebar, which says <code>Index Added</code>. Also in the terminal, you can see the file is being tracked.</p>
<blockquote>
<p>In git staging area is also called Index. Which mean staging area contain all the files updated codebase and it is ready to commit that means it will be save in the git local storage area which is in objects folder that contain commits, trees and blobs.</p>
</blockquote>
<p>Once we are at the staging area, we can now either commit the final changes or update more content → add all the changes to the staging area again, and finally commit it so that Git can store the final changes in its local storage (Object → Blob).</p>
<p>Below is the command to commit the changes.</p>
<p><code>git commit -m “short message for the changes you made”</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767885268749/06ee129e-21cd-421d-8d60-33aceeca980c.png" alt /></p>
<p>So, till now, what we have done.</p>
<ol>
<li><p>We created a folder and added the index.js file with some code.</p>
</li>
<li><p>Initialized the git repo in the same folder.</p>
</li>
<li><p>Added the <code>index.js</code> file into the staging area</p>
</li>
<li><p>Commit the staged file</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767886289522/b128cf3e-d042-4fee-a7ed-6151dc031a3a.png" alt class="image--center mx-auto" /></p>
<p>Now we are unmodified where the <code>index.js</code> has been tracked and stored in the git object storage. Simply, we can also tell that “We have committed our first version of the code.”</p>
<p>Next, we can add the new features, fix the bugs, update some code, and again move it tothe staging area and commit another version of the code.</p>
<p>So, let’s complete the code for finding weather information.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> readline = <span class="hljs-built_in">require</span>(<span class="hljs-string">'readline'</span>);

<span class="hljs-keyword">const</span> weather_report = {
    <span class="hljs-string">"jsr"</span>: {
        <span class="hljs-string">"city"</span>: <span class="hljs-string">"Jamshedpur"</span>,
        <span class="hljs-string">"temperature"</span>: <span class="hljs-string">"30°C"</span>,
        <span class="hljs-string">"condition"</span>: <span class="hljs-string">"Sunny"</span>
    },
    <span class="hljs-string">"del"</span>: {
        <span class="hljs-string">"city"</span>: <span class="hljs-string">"Delhi"</span>,
        <span class="hljs-string">"temperature"</span>: <span class="hljs-string">"35°C"</span>,
        <span class="hljs-string">"condition"</span>: <span class="hljs-string">"Hot"</span>
    },
    <span class="hljs-string">"mum"</span>: {
        <span class="hljs-string">"city"</span>: <span class="hljs-string">"Mumbai"</span>,
        <span class="hljs-string">"temperature"</span>: <span class="hljs-string">"28°C"</span>,
        <span class="hljs-string">"condition"</span>: <span class="hljs-string">"Humid"</span>
    }
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getWeatherReport</span>(<span class="hljs-params">cityCode</span>) </span>{
    <span class="hljs-keyword">const</span> report = weather_report[cityCode];
    <span class="hljs-keyword">if</span> (report) {
        <span class="hljs-keyword">return</span> <span class="hljs-string">`City: <span class="hljs-subst">${report.city}</span>, Temperature: <span class="hljs-subst">${report.temperature}</span>, Condition: <span class="hljs-subst">${report.condition}</span>`</span>;
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-string">"City code not found."</span>;
    }
}

<span class="hljs-keyword">const</span> rl = readline.createInterface({
    <span class="hljs-attr">input</span>: process.stdin,
    <span class="hljs-attr">output</span>: process.stdout
})

rl.question(<span class="hljs-string">"Enter city code (jsr, del, mum): "</span>, <span class="hljs-function">(<span class="hljs-params">cityCode</span>) =&gt;</span> {
    <span class="hljs-keyword">const</span> report = getWeatherReport(cityCode)
    <span class="hljs-built_in">console</span>.log(report)
    rl.close();
})
</code></pre>
<p>The code is simple to understand.</p>
<ol>
<li><p>We have imported <code>readline</code> (An inbuilt node package to take input from the user)</p>
</li>
<li><p><code>weather_report</code> A constant that stores the weather report of 3 different places.</p>
</li>
<li><p><code>getWeatherReport()</code> A method that takes the <code>cityCode</code> as an argument and finds the weather of the respective city and returns it in a readable way.</p>
</li>
<li><p><code>const rl = readline.createInterface({ input: process.stdin, output: process.stdout })</code> This helps Node.js to create an interface that will help us to take input from the user and show some output in the terminal via standard input and output.</p>
</li>
<li><p>And finally, we are asking the city code from the user and showing them the result.</p>
</li>
</ol>
<blockquote>
<p>Don’t worry if you don’t understand the code.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767891502316/27a9239d-5933-4a28-9e7f-58a623a5863a.png" alt class="image--center mx-auto" /></p>
<p>As you can see, as soon as we added some code after making a commit, the file status changed to <code>M</code> which means it is now in a modified state whe</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767893015926/6381d1df-f435-42e2-9eac-643a59734a15.png" alt class="image--center mx-auto" /></p>
<p>re we have updated the file. This means we have added some code to this file, but what git doesn’t know.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767892227420/4e885777-fbb2-4ad7-88a2-c4902d4de004.png" alt /></p>
<p>To make Git aware of the changes, we need to stage them again. So let’s do it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767892295174/569a942f-1ef9-4d19-a532-9c8b8f34d236.png" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767892332781/2eaf7958-4f13-4f10-8494-11ff8cd74b01.png" alt /></p>
<p>Now, as you can see, Git says clearly that this <code>index.js</code> file is modified and also staged (obviously after doing it). Now, let’s commit it so that the new version of the code is stored in the Git object storage.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767893019085/87410a37-afcd-4a3c-af2d-1ea87b047114.png" alt /></p>
<p>Now you can see in the terminal above that the working tree is clean, which means the 2nd version of code is also stored in the Git Object storage system. Also, in VS Code, you can see that there are no symbols on the right side of the file name, which confirms this.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767893115475/8cdd707b-455f-41c8-a698-7eed6da56dd7.png" alt class="image--center mx-auto" /></p>
<p>We will cover the final part, Objects &amp; Refs, in the next section of this blog since this one is already longer than usual.</p>
<p>Thank you for reading till this point. The next part will come soon.</p>
]]></content:encoded></item><item><title><![CDATA[Why the Recipe Reveal Team Opted for a Version Control System]]></title><description><![CDATA[Majorly, every software has a huge amount of code files and code in it to combine all of them and build a useful software that can solve some real world problems. And in the early days of tech evolution, we didn’t have any Version Control System, whi...]]></description><link>https://blog.baruntiwary.dev/why-the-recipe-reveal-team-opted-for-a-version-control-system</link><guid isPermaLink="true">https://blog.baruntiwary.dev/why-the-recipe-reveal-team-opted-for-a-version-control-system</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[version control]]></category><category><![CDATA[news]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Tue, 30 Dec 2025 10:06:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1767088995250/f05837d3-a056-48cc-8000-b78861267863.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Majorly, every software has a huge amount of code files and code in it to combine all of them and build a useful software that can solve some real world problems. And in the early days of tech evolution, we didn’t have any <strong>Version Control System,</strong> which led to issues like no collaboration, not being able to track which developer changed which part of the code, and more, which we will be discussing in this article with a simple analogy to get the glimpse of the importance of the <strong>Version Control Systems</strong> like <strong>Git</strong>, <strong>Mercurial, Fossil, Darcs and others</strong>.</p>
<p>Taking the analogy of the product <a target="_blank" href="https://recipereveal.in">Recipe Reveal</a> as an example, which has a decent amount of frontend and backend code in it, it provides all the Indian Recipes in a single place with a tool to track your health goals and other features. The developers faced a problem in the initial stage of building this product, which was the collaboration for different features like recipe filters component in all recipes page, personalised AI chatbot component, time-based recipe suggestion component in the hero section, and a lot of others, and tracking which team member has implemented which part of the product.</p>
<p>Initially, they used the traditional <strong>Pendrive System</strong>, where the tech lead created the first version of the product, which included just a landing page listing the top recipe of the platform, featured recipes, about Recipe Reveal, and a few other sections. He launched the product on <a target="_blank" href="https://peerlist.io/baruntiwary/project/recipereveal">PeerList</a> and shared it with his network. People loved it and demanded more features. But with the rising demand for features, the tech lead realized he couldn't implement all of them himself and decided to get help from some junior developers to ship those features. He created a zip file of the current codebase and shared it with his two junior developers on a pendrive. The first developer's task was to build the recipes page, where users could search for specific recipes from their database with premium filters, and the second developer's task was to add the AI-based personalized chatbot. Finally, the tech lead was implementing the Auth system, where users could sign up for the platform and access the features built by the team.</p>
<p>Now, as soon as the tech lead got the implemented feature on the pendrive, he realized that he had made a blunder. The pendrives looked identical, and he couldn't recognize which one contained the code he was looking for; that was fine, as he could see after inserting it into the computer. But the main problem was integrating the code provided by the developer into the code he had, because there was still a lot of work to do, and there was no point in taking help from others if he had to integrate the code himself, wasting his time. Interestingly, he was also unable to track which developer had made what changes after a certain iteration on the codebase. All three of them had their own version of the product: the tech lead had the first version with some features, the first developer had a codebase with some features, and the other developer also had his own version of the code with other features. And in the future, if the new version had a bug and it still got into production, there was no way to backtrack to the previous working version of the code and revert to it.</p>
<p>It was a total mess; the main problem was:</p>
<ol>
<li><p>Code Tracking</p>
</li>
<li><p>Collaboration</p>
</li>
</ol>
<p>So, what is the solution?</p>
<p>The tech lead comes up with the Idea to build a simple tool that they can install on a pendrive, which will track the code changes and who made the change in them, track the time, and store the different versions of the code in the same pendrive. The reason for building this tool is to solve the code tracking and debugging problem.</p>
<p>Now, whenever someone changes even a single line or character, the tool tracks who made the changes at what time, and what the changes are. And more importantly, they were able to revert to the working version of the code in case they pushed the breaking changes to production, patched the breaking changes, and again pushed the working code into production.</p>
<p>This tool solves the one major problem, which is <strong>Code Tracking.</strong> Now there is still one problem: multiple developers can’t work on the same code in parallel, and also there is confusion about which version of the code is the final one and can be pushed to production. Like the 1st developer added the filters in the recipes pages, the 2nd developer added the chat interface, and the tech lead added the authentication flow, still there are 3 different versions of the code. We still can’t finalize which version of the code should be in production, and we still need to merge all the code into a single source code manually; that may cause other issues in production.</p>
<p>This problem was addressed by creating a central server that stores all the different versions of the code using the same tool installed in the pendrive, but with additional features like maintaining a single source of truth on which developers can rely. Like, now the tech lead has completely moved all the code from the pendrive to the central server, which also has the main version of the code, which will be in production, and other versions as well. So that other developers can work independently, and after the final changes, it can be merged into the main version very easily.</p>
<p>In the market, there are a lot of similar tools like the tech lead build for their team, which are Git, Mercurial, Fossil, etc, and the central servers like Github, Gitlab, BitBucket, AWS CodeCommit, and many more.</p>
]]></content:encoded></item><item><title><![CDATA[Best advanced python course]]></title><description><![CDATA[Chapter 1: String, List, Set, Tuple, and Dictionary Operations

Project Name: Contact Management System (Basic Version)
Description: Create a simple CLI-based contact management system.
Flow and Features:

Use strings for storing names and contact de...]]></description><link>https://blog.baruntiwary.dev/best-advanced-python-course</link><guid isPermaLink="true">https://blog.baruntiwary.dev/best-advanced-python-course</guid><category><![CDATA[best advanced python course]]></category><category><![CDATA[advance python training]]></category><category><![CDATA[online advance python course]]></category><category><![CDATA[Python]]></category><category><![CDATA[python projects]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Sun, 12 Jan 2025 09:00:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736672303575/1b2bb88d-7197-4b90-93fa-f531e127b192.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-chapter-1-string-list-set-tuple-and-dictionary-operations"><strong>Chapter 1: String, List, Set, Tuple, and Dictionary Operations</strong></h1>
<hr />
<h3 id="heading-project-name-contact-management-system-basic-version"><strong>Project Name:</strong> Contact Management System (Basic Version)</h3>
<h3 id="heading-description-create-a-simple-cli-based-contact-management-system"><strong>Description:</strong> Create a simple CLI-based contact management system.</h3>
<p><strong>Flow and Features:</strong></p>
<ol>
<li><p>Use strings for storing names and contact details.</p>
</li>
<li><p>Use lists to maintain a collection of contacts.</p>
</li>
<li><p>Perform operations like adding, updating, deleting, and viewing contacts.</p>
</li>
<li><p>Use sets to ensure no duplicate contact names.</p>
</li>
<li><p>Use tuples to store immutable contact details (e.g., name, phone number).</p>
</li>
<li><p>Use dictionaries to map contact names to details for efficient searching.</p>
</li>
</ol>
<hr />
<h1 id="heading-prerequisites">Prerequisites.</h1>
<h2 id="heading-introduction-to-strings-and-in-built-data-structures">Introduction to Strings and In-Built Data Structures.</h2>
<h3 id="heading-strings-in-python"><strong>Strings in Python</strong></h3>
<p>Strings are sequences of characters enclosed in quotes. Python supports single, double, and triple quotes for strings.</p>
<h3 id="heading-creating-strings"><strong>Creating Strings:</strong></h3>
<pre><code class="lang-python"><span class="hljs-comment"># Single-quoted string</span>
greeting = <span class="hljs-string">'Hello'</span>

<span class="hljs-comment"># Double-quoted string</span>
name = <span class="hljs-string">"World"</span>

<span class="hljs-comment"># Triple-quoted string (used for multi-line strings)</span>
message = <span class="hljs-string">'''This is a
multi-line string.'''</span>
</code></pre>
<h3 id="heading-accessing-characters-in-a-string"><strong>Accessing Characters in a String:</strong></h3>
<p>Strings in Python are indexed, starting from 0 for the first character.</p>
<pre><code class="lang-python">text = <span class="hljs-string">"Python"</span>
print(text[<span class="hljs-number">0</span>])  <span class="hljs-comment"># Output: 'P'</span>
print(text[<span class="hljs-number">0</span>:<span class="hljs-number">3</span>]   <span class="hljs-comment"># Output: 'Pyt' ([startIndex: lastIndex] - select from the startIndex to lastIndex - 1)</span>
print(text[<span class="hljs-number">-1</span>]) <span class="hljs-comment"># Output: 'n' (negative index for last character)</span>
print(text[<span class="hljs-number">-2</span>])<span class="hljs-comment"># Output: 'o'</span>
</code></pre>
<h3 id="heading-common-string-methods"><strong>Common String Methods:</strong></h3>
<pre><code class="lang-python">text = <span class="hljs-string">"python programming"</span>
print(text.upper())       <span class="hljs-comment"># Output: 'PYTHON PROGRAMMING' (Converts to uppercase)</span>
print(text.lower())       <span class="hljs-comment"># Output: 'python programming' (Converts to lowercase)</span>
print(text.capitalize())  <span class="hljs-comment"># Output: 'Python programming' (Capitalizes the first character)</span>
print(text.replace(<span class="hljs-string">"python"</span>, <span class="hljs-string">"Java"</span>))  <span class="hljs-comment"># Output: 'Java Programming' Replace substring</span>
</code></pre>
<h3 id="heading-string-slicing"><strong>String Slicing:</strong></h3>
<p>You can extract a portion of a string using slicing.</p>
<pre><code class="lang-python">text = <span class="hljs-string">"Python"</span>
print(text[<span class="hljs-number">0</span>:<span class="hljs-number">3</span>])  <span class="hljs-comment"># Output: 'Pyt' (characters from index 0 to 2)</span>
print(text[:<span class="hljs-number">3</span>])   <span class="hljs-comment"># Output: 'Pyt' (same as above)</span>
print(text[<span class="hljs-number">3</span>:])   <span class="hljs-comment"># Output: 'hon' (from index 3 to the end)</span>
</code></pre>
<hr />
<h3 id="heading-lists-in-python"><strong>Lists in Python</strong></h3>
<p>A list is a collection of items (elements) that are ordered and changeable. Lists are created using square brackets <code>[]</code>.</p>
<h3 id="heading-creating-lists"><strong>Creating Lists:</strong></h3>
<pre><code class="lang-python"><span class="hljs-comment"># Creating a list of integers</span>
numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>]

<span class="hljs-comment"># Creating a mixed list</span>
mixed = [<span class="hljs-number">1</span>, <span class="hljs-string">"hello"</span>, <span class="hljs-number">3.5</span>, <span class="hljs-literal">True</span>]
</code></pre>
<h3 id="heading-accessing-list-items"><strong>Accessing List Items:</strong></h3>
<p>Lists use zero-based indexing.</p>
<pre><code class="lang-python">fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"cherry"</span>]
print(fruits[<span class="hljs-number">0</span>])  <span class="hljs-comment"># Output: 'apple'</span>
print(fruits[<span class="hljs-number">-1</span>]) <span class="hljs-comment"># Output: 'cherry'</span>
</code></pre>
<h3 id="heading-modifying-list-items"><strong>Modifying List Items:</strong></h3>
<p>Lists are mutable, so you can change their content.</p>
<pre><code class="lang-python">fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"cherry"</span>]
fruits[<span class="hljs-number">1</span>] = <span class="hljs-string">"blueberry"</span>
print(fruits)  <span class="hljs-comment"># Output: ['apple', 'blueberry', 'cherry']</span>
</code></pre>
<h3 id="heading-common-list-methods"><strong>Common List Methods:</strong></h3>
<pre><code class="lang-python">numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
numbers.append(<span class="hljs-number">4</span>)        <span class="hljs-comment"># Adds an item to the end</span>
numbers.insert(<span class="hljs-number">1</span>, <span class="hljs-number">1.5</span>)   <span class="hljs-comment"># Inserts 1.5 at index 1</span>
numbers.remove(<span class="hljs-number">2</span>)        <span class="hljs-comment"># Removes the first occurrence of 2</span>
numbers.sort()           <span class="hljs-comment"># Sorts the list</span>
print(numbers)           <span class="hljs-comment"># Output: [1, 1.5, 3, 4]</span>
</code></pre>
<h3 id="heading-list-slicing"><strong>List Slicing:</strong></h3>
<pre><code class="lang-python">numbers = [<span class="hljs-number">10</span>, <span class="hljs-number">20</span>, <span class="hljs-number">30</span>, <span class="hljs-number">40</span>, <span class="hljs-number">50</span>]
print(numbers[<span class="hljs-number">1</span>:<span class="hljs-number">4</span>])  <span class="hljs-comment"># Output: [20, 30, 40] (items at index 1, 2, and 3)</span>
print(numbers[:<span class="hljs-number">3</span>])   <span class="hljs-comment"># Output: [10, 20, 30]</span>
print(numbers[<span class="hljs-number">3</span>:])   <span class="hljs-comment"># Output: [40, 50]</span>
</code></pre>
<hr />
<h2 id="heading-121-set">1.2.1 Set</h2>
<h3 id="heading-sets-in-python"><strong>Sets in Python</strong></h3>
<p>A set is a collection of unique, unordered elements. Sets are created using curly braces <code>{}</code> or the <code>set()</code> function.</p>
<h3 id="heading-creating-a-set"><strong>Creating a Set:</strong></h3>
<pre><code class="lang-python"><span class="hljs-comment"># Using curly braces</span>
fruits = {<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"cherry"</span>}

<span class="hljs-comment"># Using the set() function</span>
numbers = set([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>])

<span class="hljs-comment"># Empty set</span>
empty_set = set()
</code></pre>
<h3 id="heading-accessing-elements-in-a-set"><strong>Accessing Elements in a Set:</strong></h3>
<p>Since sets are unordered, you cannot access elements using an index. You can use a loop:</p>
<pre><code class="lang-python"><span class="hljs-keyword">for</span> fruit <span class="hljs-keyword">in</span> fruits:
    print(fruit)
</code></pre>
<h3 id="heading-adding-deleting-and-updating-elements"><strong>Adding, Deleting, and Updating Elements:</strong></h3>
<pre><code class="lang-python"><span class="hljs-comment"># Adding elements</span>
fruits.add(<span class="hljs-string">"orange"</span>)

<span class="hljs-comment"># Removing elements</span>
fruits.remove(<span class="hljs-string">"banana"</span>)  <span class="hljs-comment"># Raises an error if not found</span>
fruits.discard(<span class="hljs-string">"banana"</span>) <span class="hljs-comment"># Does not raise an error</span>

<span class="hljs-comment"># Updating with multiple elements</span>
fruits.update([<span class="hljs-string">"kiwi"</span>, <span class="hljs-string">"mango"</span>])
</code></pre>
<h3 id="heading-python-set-operations"><strong>Python Set Operations:</strong></h3>
<pre><code class="lang-python">A = {<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>}
B = {<span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>}

print(A.union(B))        <span class="hljs-comment"># Output: {1, 2, 3, 4, 5}</span>
print(A.intersection(B)) <span class="hljs-comment"># Output: {3}</span>
print(A.difference(B))   <span class="hljs-comment"># Output: {1, 2}</span>
print(A.symmetric_difference(B)) <span class="hljs-comment"># Output: {1, 2, 4, 5}</span>
</code></pre>
<hr />
<h2 id="heading-131-tuple">1.3.1 Tuple</h2>
<h3 id="heading-tuples-in-python"><strong>Tuples in Python</strong></h3>
<p>A tuple is an immutable, ordered collection of elements. Tuples are created using parentheses <code>()</code>.</p>
<h3 id="heading-creating-tuples"><strong>Creating Tuples:</strong></h3>
<pre><code class="lang-python"><span class="hljs-comment"># Empty tuple</span>
empty_tuple = ()

<span class="hljs-comment"># Tuple with elements</span>
numbers = (<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)

<span class="hljs-comment"># Mixed tuple</span>
mixed = (<span class="hljs-number">1</span>, <span class="hljs-string">"hello"</span>, <span class="hljs-number">3.5</span>)
</code></pre>
<h3 id="heading-accessing-tuples"><strong>Accessing Tuples:</strong></h3>
<p>You can use indexing and slicing with tuples just like lists.</p>
<pre><code class="lang-python">tuple_data = (<span class="hljs-string">"a"</span>, <span class="hljs-string">"b"</span>, <span class="hljs-string">"c"</span>, <span class="hljs-string">"d"</span>)
print(tuple_data[<span class="hljs-number">1</span>])    <span class="hljs-comment"># Output: 'b'</span>
print(tuple_data[<span class="hljs-number">1</span>:<span class="hljs-number">3</span>])  <span class="hljs-comment"># Output: ('b', 'c')</span>
</code></pre>
<h3 id="heading-tuples-are-immutable"><strong>Tuples are Immutable:</strong></h3>
<p>Tuples cannot be modified after creation.</p>
<pre><code class="lang-python">numbers = (<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
<span class="hljs-comment"># numbers[1] = 4  # This will raise a TypeError</span>
</code></pre>
<h3 id="heading-built-in-tuple-functions"><strong>Built-In Tuple Functions:</strong></h3>
<pre><code class="lang-python">numbers = (<span class="hljs-number">10</span>, <span class="hljs-number">20</span>, <span class="hljs-number">30</span>)
print(len(numbers))      <span class="hljs-comment"># Output: 3</span>
print(max(numbers))      <span class="hljs-comment"># Output: 30</span>
print(min(numbers))      <span class="hljs-comment"># Output: 10</span>
</code></pre>
<hr />
<h2 id="heading-141-dictionary">1.4.1 Dictionary</h2>
<h3 id="heading-dictionaries-in-python"><strong>Dictionaries in Python</strong></h3>
<p>A dictionary is an unordered collection of key-value pairs. Keys must be unique, and values can be of any type.</p>
<h3 id="heading-creating-dictionaries"><strong>Creating Dictionaries:</strong></h3>
<pre><code class="lang-python"><span class="hljs-comment"># Using curly braces</span>
details = {<span class="hljs-string">"name"</span>: <span class="hljs-string">"Alice"</span>, <span class="hljs-string">"age"</span>: <span class="hljs-number">25</span>, <span class="hljs-string">"city"</span>: <span class="hljs-string">"New York"</span>}

<span class="hljs-comment"># Using the dict() function</span>
details = dict(name=<span class="hljs-string">"Bob"</span>, age=<span class="hljs-number">30</span>, city=<span class="hljs-string">"London"</span>)
</code></pre>
<h3 id="heading-accessing-items-in-dictionaries"><strong>Accessing Items in Dictionaries:</strong></h3>
<pre><code class="lang-python">details = {<span class="hljs-string">"name"</span>: <span class="hljs-string">"Alice"</span>, <span class="hljs-string">"age"</span>: <span class="hljs-number">25</span>}
print(details[<span class="hljs-string">"name"</span>])  <span class="hljs-comment"># Output: 'Alice'</span>
print(details.get(<span class="hljs-string">"age"</span>)) <span class="hljs-comment"># Output: 25</span>
</code></pre>
<h3 id="heading-adding-upda"><strong>Adding, Upda</strong></h3>
<p><strong>ting, and Removing Items:</strong></p>
<pre><code class="lang-python"><span class="hljs-comment"># Adding or updating</span>
details[<span class="hljs-string">"city"</span>] = <span class="hljs-string">"Paris"</span>

<span class="hljs-comment"># Removing</span>
removed = details.pop(<span class="hljs-string">"age"</span>)  <span class="hljs-comment"># Removes 'age' and returns its value</span>
details.clear()  <span class="hljs-comment"># Clears the entire dictionary</span>
</code></pre>
<h3 id="heading-properties-of-dictionary-keys"><strong>Properties of Dictionary Keys:</strong></h3>
<ul>
<li><p>Keys must be unique.</p>
</li>
<li><p>Keys must be immutable (e.g., strings, numbers, tuples).</p>
</li>
</ul>
<h3 id="heading-built-in-dictionary-methods"><strong>Built-In Dictionary Methods:</strong></h3>
<pre><code class="lang-python">details = {<span class="hljs-string">"name"</span>: <span class="hljs-string">"Alice"</span>, <span class="hljs-string">"age"</span>: <span class="hljs-number">25</span>}
print(details.keys())    <span class="hljs-comment"># Output: dict_keys(['name', 'age'])</span>
print(details.values())  <span class="hljs-comment"># Output: dict_values(['Alice', 25])</span>
print(details.items())   <span class="hljs-comment"># Output: dict_items([('name', 'Alice'), ('age', 25)]</span>
</code></pre>
<hr />
<h1 id="heading-project">Project</h1>
<pre><code class="lang-python"><span class="hljs-comment"># Contact Management System (Basic Version)</span>
<span class="hljs-comment"># This program is a simple CLI-based contact management system that demonstrates</span>
<span class="hljs-comment"># the use of strings, lists, sets, tuples, and dictionaries in Python.</span>

<span class="hljs-comment"># Contact management system data structure</span>
<span class="hljs-comment"># Dictionary to map contact names (keys) to tuples containing contact details (values)</span>
contacts = {}

<span class="hljs-comment"># Set to ensure no duplicate contact names</span>
contact_names = set()

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">add_contact</span>():</span>
    <span class="hljs-string">"""Adds a new contact to the system."""</span>
    name = input(<span class="hljs-string">"Enter contact name: "</span>).strip()
    <span class="hljs-keyword">if</span> name <span class="hljs-keyword">in</span> contact_names:
        print(<span class="hljs-string">f"Contact with name '<span class="hljs-subst">{name}</span>' already exists.\\n"</span>)
        <span class="hljs-keyword">return</span>

    phone = input(<span class="hljs-string">"Enter phone number: "</span>).strip()
    email = input(<span class="hljs-string">"Enter email address: "</span>).strip()

    <span class="hljs-comment"># Use a tuple to store immutable contact details</span>
    contact_details = (phone, email)

    <span class="hljs-comment"># Add to dictionary and set</span>
    contacts[name] = contact_details
    contact_names.add(name)
    print(<span class="hljs-string">f"Contact '<span class="hljs-subst">{name}</span>' added successfully.\\n"</span>)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">view_contacts</span>():</span>
    <span class="hljs-string">"""Displays all contacts in the system."""</span>
    <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> contacts:
        print(<span class="hljs-string">"No contacts available.\\n"</span>)
        <span class="hljs-keyword">return</span>

    print(<span class="hljs-string">"\\n--- Contact List ---"</span>)
    <span class="hljs-keyword">for</span> name, details <span class="hljs-keyword">in</span> contacts.items():
        phone, email = details
        print(<span class="hljs-string">f"Name: <span class="hljs-subst">{name}</span>, Phone: <span class="hljs-subst">{phone}</span>, Email: <span class="hljs-subst">{email}</span>"</span>)
    print()

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">update_contact</span>():</span>
    <span class="hljs-string">"""Updates an existing contact."""</span>
    name = input(<span class="hljs-string">"Enter the name of the contact to update: "</span>).strip()
    <span class="hljs-keyword">if</span> name <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> contact_names:
        print(<span class="hljs-string">f"Contact '<span class="hljs-subst">{name}</span>' does not exist.\\n"</span>)
        <span class="hljs-keyword">return</span>

    phone = input(<span class="hljs-string">"Enter new phone number: "</span>).strip()
    email = input(<span class="hljs-string">"Enter new email address: "</span>).strip()

    <span class="hljs-comment"># Update contact details</span>
    contacts[name] = (phone, email)
    print(<span class="hljs-string">f"Contact '<span class="hljs-subst">{name}</span>' updated successfully.\\n"</span>)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">delete_contact</span>():</span>
    <span class="hljs-string">"""Deletes a contact from the system."""</span>
    name = input(<span class="hljs-string">"Enter the name of the contact to delete: "</span>).strip()
    <span class="hljs-keyword">if</span> name <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> contact_names:
        print(<span class="hljs-string">f"Contact '<span class="hljs-subst">{name}</span>' does not exist.\\n"</span>)
        <span class="hljs-keyword">return</span>

    <span class="hljs-comment"># Remove from dictionary and set</span>
    <span class="hljs-keyword">del</span> contacts[name]
    contact_names.remove(name)
    print(<span class="hljs-string">f"Contact '<span class="hljs-subst">{name}</span>' deleted successfully.\\n"</span>)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">search_contact</span>():</span>
    <span class="hljs-string">"""Searches for a contact by name."""</span>
    name = input(<span class="hljs-string">"Enter the name of the contact to search: "</span>).strip()
    <span class="hljs-keyword">if</span> name <span class="hljs-keyword">in</span> contacts:
        phone, email = contacts[name]
        print(<span class="hljs-string">f"\\nContact found: Name: <span class="hljs-subst">{name}</span>, Phone: <span class="hljs-subst">{phone}</span>, Email: <span class="hljs-subst">{email}</span>\\n"</span>)
    <span class="hljs-keyword">else</span>:
        print(<span class="hljs-string">f"Contact '<span class="hljs-subst">{name}</span>' not found.\\n"</span>)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main_menu</span>():</span>
    <span class="hljs-string">"""Displays the main menu and handles user input."""</span>
    <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:
        print(<span class="hljs-string">"\\n--- Contact Management System ---"</span>)
        print(<span class="hljs-string">"1. Add Contact"</span>)
        print(<span class="hljs-string">"2. View Contacts"</span>)
        print(<span class="hljs-string">"3. Update Contact"</span>)
        print(<span class="hljs-string">"4. Delete Contact"</span>)
        print(<span class="hljs-string">"5. Search Contact"</span>)
        print(<span class="hljs-string">"6. Exit"</span>)

        choice = input(<span class="hljs-string">"Enter your choice (1-6): "</span>).strip()

        <span class="hljs-keyword">if</span> choice == <span class="hljs-string">'1'</span>:
            add_contact()
        <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">'2'</span>:
            view_contacts()
        <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">'3'</span>:
            update_contact()
        <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">'4'</span>:
            delete_contact()
        <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">'5'</span>:
            search_contact()
        <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">'6'</span>:
            print(<span class="hljs-string">"Exiting Contact Management System. Goodbye!"</span>)
            <span class="hljs-keyword">break</span>
        <span class="hljs-keyword">else</span>:
            print(<span class="hljs-string">"Invalid choice. Please try again.\\n"</span>)

<span class="hljs-comment"># Run the main menu</span>
<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    main_menu()
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Teach coding yourself effectively in 2025]]></title><description><![CDATA[How to Teach Yourself Coding in 2025: A Comprehensive Guide
Coding is an invaluable skill in today's tech-driven world, and with the resources available in 2025, teaching yourself to code has never been more accessible. Whether you aspire to become a...]]></description><link>https://blog.baruntiwary.dev/teach-coding-yourself-effectively-in-2025</link><guid isPermaLink="true">https://blog.baruntiwary.dev/teach-coding-yourself-effectively-in-2025</guid><category><![CDATA[teaching]]></category><category><![CDATA[Technical writing ]]></category><category><![CDATA[technology]]></category><category><![CDATA[coding]]></category><category><![CDATA[newbie]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Wed, 01 Jan 2025 12:46:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1735999795214/a5d674dd-e0e7-467b-a385-076adefbbd42.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>How to Teach Yourself Coding in 2025: A Comprehensive Guide</strong></p>
<p>Coding is an invaluable skill in today's tech-driven world, and with the resources available in 2025, teaching yourself to code has never been more accessible. Whether you aspire to become a web developer, data scientist, or software engineer, this guide will walk you through the steps to master coding on your own.</p>
<h3 id="heading-step-1-define-your-goals">Step 1: Define Your Goals</h3>
<p>Before diving in, it's essential to clarify why you want to learn coding. Are you building a web app? Pursuing a tech career? Creating a personal project? Defining your goals will help you choose the right programming languages and learning resources.</p>
<h3 id="heading-step-2-choose-the-right-programming-language">Step 2: Choose the Right Programming Language</h3>
<p>Not all programming languages are created equal, and the best one to start with depends on your goals:</p>
<ul>
<li><p><strong>Web Development</strong>: HTML, CSS, JavaScript, and frameworks like React or Angular.</p>
</li>
<li><p><strong>Data Science &amp; Machine Learning</strong>: Python, R, and SQL.</p>
</li>
<li><p><strong>Mobile App Development</strong>: Swift for iOS, Kotlin for Android, or React Native for cross-platform apps.</p>
</li>
<li><p><strong>Game Development</strong>: C# with Unity or C++ for Unreal Engine.</p>
</li>
<li><p><strong>General Software Development</strong>: Java, Python, or C++.</p>
</li>
</ul>
<h3 id="heading-step-3-leverage-online-platforms-and-resources">Step 3: Leverage Online Platforms and Resources</h3>
<p>2025 offers a plethora of platforms to learn to code effectively:</p>
<ol>
<li><p><strong>Interactive Platforms</strong>: Codecademy, freeCodeCamp, and LeetCode for hands-on coding.</p>
</li>
<li><p><strong>Video Tutorials</strong>: YouTube channels like <a target="_blank" href="https://www.youtube.com/@piyushgargdev">Piyush Garg</a>, <a target="_blank" href="https://www.youtube.com/@chaiaurcode">Chai aur Code</a>, and <a target="_blank" href="https://www.youtube.com/@codewithharry">CodeWithHarry</a>.</p>
</li>
<li><p><strong>Online Courses</strong>: Platforms like Udemy, Coursera, and edX.</p>
</li>
<li><p><strong>Documentation and Blogs</strong>: Read official documentation and follow tech blogs for in-depth understanding.</p>
</li>
</ol>
<h3 id="heading-step-4-practice-regularly">Step 4: Practice Regularly</h3>
<p>Consistency is key when learning to code. Dedicate at least an hour daily to practice. Start with small projects like a personal website or a calculator app, and gradually tackle more complex tasks.</p>
<h3 id="heading-step-5-join-coding-communities">Step 5: Join Coding Communities</h3>
<p>Engage with online and local coding communities. Platforms like GitHub, Stack Overflow, and Reddit (‘r/learnprogramming’) are excellent for sharing your progress, seeking help, and networking with other learners and professionals.</p>
<h3 id="heading-step-6-build-real-world-projects">Step 6: Build Real-World Projects</h3>
<p>Hands-on experience is critical. Start by solving real-world problems or contributing to open-source projects. Building projects like a to-do list app, blog, or e-commerce site will help you solidify your skills.</p>
<h3 id="heading-step-7-leverage-ai-tools">Step 7: Leverage AI Tools</h3>
<p>In 2025, AI-driven coding assistants like GitHub Copilot, ChatGPT, and <a target="_blank" href="http://Bolt.New">Bolt.New</a> can accelerate your learning. Use these tools to understand code syntax, debug issues, and explore advanced concepts effortlessly.</p>
<h3 id="heading-step-8-embrace-failure-and-debugging">Step 8: Embrace Failure and Debugging</h3>
<p>Mistakes are inevitable in coding. Learn to debug efficiently by using tools like browser developer tools, logging techniques, and debugger utilities in IDEs. Debugging is a skill in itself, and mastering it will make you a better coder.</p>
<h3 id="heading-step-9-expand-your-knowledge">Step 9: Expand Your Knowledge</h3>
<p>Once comfortable with basics, explore advanced topics:</p>
<ul>
<li><p>Algorithms and data structures</p>
</li>
<li><p>Design patterns and software architecture</p>
</li>
<li><p>Version control systems like Git</p>
</li>
<li><p>Frameworks and libraries for your chosen language</p>
</li>
</ul>
<h3 id="heading-step-10-stay-updated">Step 10: Stay Updated</h3>
<p>Technology evolves rapidly. Subscribe to newsletters, follow tech influencers, and stay updated with the latest trends. Regularly revisit and refine your skills to stay relevant in the ever-changing tech landscape.</p>
<h3 id="heading-final-thoughts">Final Thoughts</h3>
<p>Learning to code is a journey that requires dedication, patience, and a curious mindset. With the abundance of resources available in 2025, teaching yourself coding has never been more feasible. Follow these steps, stay consistent, and you'll be on your way to mastering coding and achieving your goals.</p>
<p>Happy coding!</p>
]]></content:encoded></item><item><title><![CDATA[How to Upload and Update a React Project on GitHub Using Drag and Drop]]></title><description><![CDATA[GitHub makes sharing and managing projects easy, even if you’re not technical. If you’ve built a React project and want to upload it to GitHub without using advanced tools like Git, this guide is for you. We'll use GitHub's drag-and-drop feature to u...]]></description><link>https://blog.baruntiwary.dev/how-to-upload-and-update-a-react-project-on-github-using-drag-and-drop</link><guid isPermaLink="true">https://blog.baruntiwary.dev/how-to-upload-and-update-a-react-project-on-github-using-drag-and-drop</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Developer]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Barun Tiwary]]></dc:creator><pubDate>Fri, 06 Dec 2024 10:05:28 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1766925207871/3cf729f6-2153-4ec1-8423-4fd72611334c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>GitHub makes sharing and managing projects easy, even if you’re not technical. If you’ve built a React project and want to upload it to GitHub without using advanced tools like Git, this guide is for you. We'll use GitHub's drag-and-drop feature to upload and update your project.</p>
<h3 id="heading-step-1-create-a-github-account"><strong>Step 1: Create a GitHub Account</strong></h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733589866493/f782a816-3a15-477a-adfe-72ac9cfbe1b4.png" alt class="image--center mx-auto" /></p>
<p>1. Visit GitHub: Go to GitHub.com.</p>
<p>2. Sign Up: Click on Sign up in the top-right corner.</p>
<p>3. Fill in Your Details: Choose a username, email, and password.</p>
<p>4. Verify Your Email: Check your inbox and confirm your email address.</p>
<h3 id="heading-step-2-create-a-new-repository"><strong>Step 2: Create a New Repository</strong></h3>
<p>1. Log in to GitHub</p>
<p>2. Create a Repository:</p>
<p>Click the + icon in the top-right corner and select New repository.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733590035084/d0bb4bb5-b38f-4374-8f39-2ba1169961eb.png" alt class="image--center mx-auto" /></p>
<p>Enter a repository name (e.g., "React-Portfolio").</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733589977882/f6c52447-b39e-4fc3-92f2-b74adcc637cb.png" alt class="image--center mx-auto" /></p>
<p>Add an optional description if needed.</p>
<p>Choose between Public (visible to everyone) or Private (only you can access it).</p>
<p>Click Create repository.</p>
<h3 id="heading-step-3-upload-your-react-project"><strong>Step 3: Upload Your React Project</strong></h3>
<p>1. Build Your React Project</p>
<p>To ensure you're uploading the optimized version of your project:</p>
<p>Open your project in a terminal.</p>
<p>Run the command:</p>
<p><code>npm run build</code></p>
<p>This will create a build folder in your project directory, which contains the optimized version of your React app.</p>
<p>2. Upload to GitHub</p>
<p>1. Open the repository you created on GitHub.</p>
<p>2. Click <code>upload existing files</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733590348877/a3279a1a-5af2-41e3-b9f6-e5f8828f735f.png" alt class="image--center mx-auto" /></p>
<p>3. Drag and drop the contents of the build folder into the upload area.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733590296849/1295a2d5-0f6f-4723-a6aa-2b9dc3876372.png" alt class="image--center mx-auto" /></p>
<p>4. Add a commit message (e.g., "Initial upload of React project").</p>
<p>5. Click Commit changes to finalize the upload</p>
<h3 id="heading-step-4-update-your-react-project"><strong>Step 4: Update Your React Project</strong></h3>
<p>Whenever you make changes to your React project and need to update it on GitHub, follow these steps:</p>
<p>1. Build the Updated Project</p>
<p>After making changes, rebuild your project by running:</p>
<p><code>npm run build</code></p>
<p>This will update the build folder with your latest changes.</p>
<p>2. Upload the Updated Files</p>
<p>1. Open your repository on GitHub.</p>
<p>2. Click Add file &gt; Upload files</p>
<p>3. Drag and drop the updated files from your build folder.</p>
<p>You can upload only the updated files or replace all files in the repository.</p>
<p>4. Add a commit message (e.g., "Updated project with new features").</p>
<p>5. Click Commit changes to save the updates.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Using GitHub’s drag-and-drop feature, you can easily upload and update your React projects without needing technical tools like Git. This method is beginner-friendly and</p>
<p>perfect for quickly sharing your work online. Keep your repository updated to reflect the latest version of your project.</p>
]]></content:encoded></item></channel></rss>