<?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[Learn with Prakash]]></title><description><![CDATA[My name is 𝐏𝐫𝐚𝐤𝐚𝐬𝐡 and I talk about 𝗧𝗲𝗰𝗵-𝐊𝐧𝐨𝐰𝐥𝐞𝐝𝐠𝐞, 𝗪𝗲𝗯𝗗𝗲𝘃, 𝗗𝗲𝘃𝗢𝗽𝘀 and 𝗟𝗶𝗳𝗲𝘀𝘁𝘆𝗹𝗲.]]></description><link>https://blog.prakashtsx.me</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 02:02:06 GMT</lastBuildDate><atom:link href="https://blog.prakashtsx.me/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding Objects in JavaScript]]></title><description><![CDATA[If you've been learning JavaScript, you've likely used Arrays to store lists of data. But what happens when you need to describe something more complex — like a person, a car, or a laptop?
An array li]]></description><link>https://blog.prakashtsx.me/js-objects</link><guid isPermaLink="true">https://blog.prakashtsx.me/js-objects</guid><category><![CDATA[javascript objects]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Sun, 29 Mar 2026 12:36:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/5b015f9d-eb95-43e0-aabd-f4f939189f44.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you've been learning JavaScript, you've likely used Arrays to store lists of data. But what happens when you need to describe something more complex — like a person, a car, or a laptop?</p>
<p>An array like <code>["MacBook", 16, 2026]</code> doesn't tell us much. What does the <code>16</code> mean? RAM? Screen size? Price in thousands?</p>
<p>That is where <strong>Objects</strong> come to the rescue!</p>
<hr />
<h3>1. Why Objects? The Problem with Arrays</h3>
<p>Before we learn what objects <em>are</em>, let's understand the problem they <em>solve</em>. Imagine you're building a user profile for a website. You might start with an array:</p>
<pre><code class="language-javascript">// What does each value mean?? 
const user = ["Prakash", 20, "Rajasthan", true, "developer"];

// To get the profession, you need to remember it's at index 4
console.log(user[4]); // "developer" — but why 4? Who knows!
</code></pre>
<p>This is a nightmare. Index numbers are <strong>meaningless</strong>. If you add a new field in the middle, every index after it breaks. Your code becomes impossible to read and maintain.</p>
<p>Now here's the same data as an object:</p>
<pre><code class="language-javascript">// Crystal clear — no guessing!
const user = {
  name: "Prakash",
  age: 20,
  state: "Rajasthan",
  isLoggedIn: true,
  profession: "developer"
};

// Now it's obvious what you're getting
console.log(user.profession); // "developer" — perfectly readable!
</code></pre>
<blockquote>
<p>💡 <strong>Rule of Thumb:</strong> Use an <strong>Array</strong> when you have a <em>list</em> of similar items (e.g., a list of product names). Use an <strong>Object</strong> when you're describing a <em>single thing</em> with multiple different attributes.</p>
</blockquote>
<h3>2. What Are Objects? The Key-Value Structure</h3>
<p>In JavaScript, an <strong>object</strong> is a standalone entity that holds related data together. Think of it like a real-world object. A car has a color, a brand, and a top speed. In code, an object allows us to group these related variables into one neat package.</p>
<p>Objects work on a <strong>key-value pair</strong> system:</p>
<ul>
<li><p><strong>Key</strong> → The name/label of the property (e.g., <code>name</code>)</p>
</li>
<li><p><strong>Value</strong> → The data assigned to that label (e.g., <code>"Prakash"</code>)</p>
</li>
</ul>
<p>Think of it like filling out a form:</p>
<table>
<thead>
<tr>
<th>Key</th>
<th>:</th>
<th>Value</th>
</tr>
</thead>
<tbody><tr>
<td><code>name</code></td>
<td>:</td>
<td><code>"Prakash"</code></td>
</tr>
<tr>
<td><code>age</code></td>
<td>:</td>
<td><code>20</code></td>
</tr>
<tr>
<td><code>state</code></td>
<td>:</td>
<td><code>"Rajasthan"</code></td>
</tr>
<tr>
<td><code>isStudent</code></td>
<td>:</td>
<td><code>true</code></td>
</tr>
</tbody></table>
<p>Values can be <strong>any data type</strong> - strings, numbers, booleans, arrays, or even other objects.</p>
<hr />
<h3>3. Creating an Object</h3>
<p>The most common way to create an object is using <strong>Object Literals</strong> the curly braces <code>{}</code>.</p>
<pre><code class="language-javascript">// A real-world example: A Person Object
const person = {
  name: "Prakash",
  age: 20,
  state: "Rajasthan"
};
</code></pre>
<p>Each key-value pair is separated by a <strong>comma</strong>. The key and value are separated by a <strong>colon</strong>.</p>
<p>You might also see the <code>new Object()</code> syntax in older code:</p>
<pre><code class="language-javascript">// The verbose way — avoid this in modern JS
const person = new Object();
person.name = "Prakash";
person.age = 20;
person.state = "Rajasthan";
</code></pre>
<blockquote>
<p><strong>Best Practice:</strong> Always use Object Literals <code>{}</code>. They're shorter, more readable, and the standard in modern JavaScript.</p>
</blockquote>
<h3>4. Accessing Properties — Two Ways</h3>
<p>Once you have an object, you need to <em>read</em> its data. JavaScript gives you two ways to do this.</p>
<p><strong>A. Dot Notation (Most Common)</strong></p>
<p>Use this when you know the property name upfront. Clean and readable.</p>
<pre><code class="language-javascript">const person = {
  name: "Prakash",
  age: 20,
  state: "Rajasthan",
  skills: ["JavaScript", "React", "Node.js"]
};

console.log(person.name);      // "Prakash"
console.log(person.age);       // 20
console.log(person.skills);    // ["JavaScript", "React", "Node.js"]

// You can chain it to access items inside an array!
console.log(person.skills[0]); // "JavaScript"
</code></pre>
<p><strong>B. Bracket Notation</strong></p>
<p>Use this when the key has a <strong>space</strong>, starts with a <strong>number</strong>, or when you're using a <strong>variable</strong> to look up a key dynamically.</p>
<pre><code class="language-javascript">const profile = {
  name: "Prakash",
  age: 20,
  "full name": "Prakash Kumar",  // key with a SPACE
  "2024score": 95                // key starting with a number
};

// CASE 1: Key has a space (dot notation would crash here!)
console.log(profile["full name"]); // "Prakash Kumar"
// profile.full name ← this would be a SYNTAX ERROR ❌

// CASE 2: Dynamic access with a variable
const query = "age";
console.log(profile[query]);       // 20 — reads the variable, not literal "query"

// CASE 3: Looping with bracket notation
const keys = ["name", "age"];
keys.forEach(key =&gt; {
  console.log(profile[key]); // "Prakash", then 20
});
</code></pre>
<blockquote>
<p><strong>Pro Tip:</strong> Bracket notation is incredibly useful when building search features or filters — any time the key is determined at runtime (from user input, for example).</p>
</blockquote>
<hr />
<h3>5. Updating, Adding &amp; Deleting Properties</h3>
<p>Objects are <strong>mutable</strong> - you can freely change them after creation. Even if you declare the object with <code>const</code>, its properties can still be modified.</p>
<p><strong>Updating a Property</strong></p>
<pre><code class="language-javascript">const person = {
  name: "Prakash",
  age: 20,
  state: "Rajasthan"
};

person.age = 21; // Prakash just had a birthday! 🎂
console.log(person.age); // 21
</code></pre>
<p><strong>Adding a New Property</strong></p>
<pre><code class="language-javascript">person.isStudent = true;
person.college = "IIT Jodhpur";

console.log(person);
// { name: "Prakash", age: 21, state: "Rajasthan", isStudent: true, college: "IIT Jodhpur" }
</code></pre>
<p><strong>Deleting a Property</strong></p>
<pre><code class="language-javascript">delete person.state;

console.log(person.state); // undefined
</code></pre>
<p><strong>Checking if a Property Exists</strong></p>
<pre><code class="language-javascript">console.log("isStudent" in person); // true
console.log("state" in person);     // false — we deleted it!
</code></pre>
<blockquote>
<p><strong>Why</strong> <code>const</code> <strong>doesn't freeze objects:</strong> <code>const</code> prevents you from doing <code>person = {}</code> (reassigning the variable). But it doesn't stop you from modifying what's <em>inside</em> the object. Use <code>Object.freeze(person)</code> if you truly want an immutable object.</p>
</blockquote>
<hr />
<h3>6. Array vs Object — What's the Difference?</h3>
<p>This trips up a lot of beginners. Here's the definitive breakdown:</p>
<table>
<thead>
<tr>
<th>Feature</th>
<th>Array <code>[]</code></th>
<th>Object <code>{}</code></th>
</tr>
</thead>
<tbody><tr>
<td><strong>Purpose</strong></td>
<td>An ordered list of similar items</td>
<td>Description of one specific thing</td>
</tr>
<tr>
<td><strong>Access</strong></td>
<td><code>arr[0]</code> — by index number</td>
<td><code>obj.key</code> — by name</td>
</tr>
<tr>
<td><strong>Ordering</strong></td>
<td>Ordered — index 0, 1, 2...</td>
<td>Unordered — key-based</td>
</tr>
<tr>
<td><strong>When to use</strong></td>
<td>Shopping cart items, scores, names</td>
<td>A user, a product, a car</td>
</tr>
<tr>
<td><strong>Loop type</strong></td>
<td><code>for...of</code> or <code>forEach</code></td>
<td><code>for...in</code></td>
</tr>
</tbody></table>
<pre><code class="language-javascript">// Use ARRAY when all items are the same kind of thing
const students = ["Prakash", "Riya", "Arjun", "Meera"];
const scores   = [85, 92, 78, 96];

// Use OBJECT when describing one specific entity
const student = {
  name: "Prakash",
  score: 85,
  grade: "A",
  passed: true
};

// COMBINE BOTH: Array of Objects — an extremely common pattern!
const classroom = [
  { name: "Prakash", score: 85, grade: "A"  },
  { name: "Riya",    score: 92, grade: "A+" },
  { name: "Arjun",   score: 78, grade: "B+" }
];

// Access: first student's name
console.log(classroom[0].name);  // "Prakash"
console.log(classroom[1].grade); // "A+"
</code></pre>
<p><strong>Array of Objects</strong> is one of the most common patterns in real-world JavaScript — you'll see this in every API response, database query result, and React component.</p>
<h3>7. Looping Through an Object</h3>
<p>To walk through every key-value pair in an object, we use the <code>for...in</code> loop.</p>
<pre><code class="language-javascript">const person = {
  name: "Prakash",
  age: 21,
  isStudent: true,
  college: "IIT Jodhpur"
};

// for...in gives you each KEY one at a time
for (let key in person) {
  console.log(key + ": " + person[key]);
}

// Output:
// name: Prakash
// age: 21
// isStudent: true
// college: IIT Jodhpur
</code></pre>
<h3>Object Utility Methods</h3>
<p>JavaScript also provides three handy built-in methods to extract parts of an object as arrays:</p>
<pre><code class="language-javascript">const person = { name: "Prakash", age: 21, college: "IIT Jodhpur" };

// Object.keys() → array of all keys
console.log(Object.keys(person));
// ["name", "age", "college"]

// Object.values() → array of all values
console.log(Object.values(person));
// ["Prakash", 21, "IIT Jodhpur"]

// Object.entries() → array of [key, value] pairs
console.log(Object.entries(person));
// [["name","Prakash"], ["age",21], ["college","IIT Jodhpur"]]

// Practical use: loop with destructuring
for (const [key, value] of Object.entries(person)) {
  console.log(`\({key} → \){value}`);
}
</code></pre>
<h3>8. Nested Objects &amp; Methods</h3>
<p>Objects can contain other objects inside them — this is called <strong>nesting</strong>. Objects can also hold functions as values — these are called <strong>methods</strong>.</p>
<p><strong>Nested Objects</strong></p>
<pre><code class="language-javascript">const student = {
  name: "Prakash",
  age: 21,

  // Nested object: address lives inside student
  address: {
    city: "Jodhpur",
    state: "Rajasthan",
    pincode: "342001"
  },

  // Array inside an object
  skills: ["JavaScript", "React", "Node.js"]
};

// Access nested properties: chain the dots
console.log(student.address.city);   // "Jodhpur"
console.log(student.address.state);  // "Rajasthan"
console.log(student.skills[0]);      // "JavaScript"

// Update a nested property
student.address.city = "Jaipur"; // Prakash moved cities!
</code></pre>
<p><strong>Methods — Functions Inside Objects</strong></p>
<pre><code class="language-javascript">const calculator = {
  brand: "Casio",

  // Functions stored as values are called "methods"
  add: function(a, b) {
    return a + b;
  },

  // Modern shorthand (preferred)
  multiply(a, b) {
    return a * b;
  },

  subtract(a, b) {
    return a - b;
  }
};

console.log(calculator.add(10, 5));      // 15
console.log(calculator.multiply(4, 3));  // 12
console.log(calculator.subtract(9, 4));  // 5
</code></pre>
<hr />
<h3>9. Real-World Example - E-Commerce Product</h3>
<p>Let's put everything together with the kind of data structure you'd actually use when building an e-commerce site.</p>
<pre><code class="language-javascript">const product = {
  id: "MBP-001",
  name: "MacBook Pro 14",
  brand: "Apple",
  price: 199999,       // in rupees ₹
  inStock: true,
  rating: 4.8,
  reviewCount: 2341,

  // Nested object
  specs: {
    chip: "Apple M3 Pro",
    ram: 18,
    storage: 512,
    display: "14.2-inch Liquid Retina XDR",
    battery: "22 hours"
  },

  // Array of strings
  colors: ["Space Black", "Silver"],

  // Array of objects
  reviews: [
    { user: "Riya_Dev",  stars: 5, comment: "Incredible performance!" },
    { user: "TechArjun", stars: 4, comment: "Great but expensive" }
  ],

  // Methods
  getDescription() {
    return `\({this.name} by \){this.brand} — ₹${this.price.toLocaleString()}`;
  },

  isAffordable(budget) {
    return this.price &lt;= budget;
  }
};

// Reading various properties
console.log(product.name);              // "MacBook Pro 14"
console.log(product.specs.ram);         // 18
console.log(product.colors[0]);         // "Space Black"
console.log(product.reviews[0].user);   // "Riya_Dev"
console.log(product.reviews[0].stars);  // 5

// Calling methods
console.log(product.getDescription());
// "MacBook Pro 14 by Apple — ₹1,99,999"

console.log(product.isAffordable(150000)); // false
console.log(product.isAffordable(250000)); // true

// Looping through specs
console.log("=== Tech Specs ===");
for (let spec in product.specs) {
  console.log(`  \({spec}: \){product.specs[spec]}`);
}
// chip: Apple M3 Pro
// ram: 18
// storage: 512
// display: 14.2-inch Liquid Retina XDR
// battery: 22 hours
</code></pre>
<p>This is almost exactly the kind of data you'd receive from a backend API. The ability to navigate nested objects, loop through properties, and call methods is a <strong>daily reality</strong> as a JavaScript developer.</p>
<hr />
<h3>Where You'll Use Objects Every Day</h3>
<ul>
<li><p><strong>User Auth &amp; Profiles</strong> — <code>{ id, name, email, role, avatar }</code></p>
</li>
<li><p><strong>Shopping Cart</strong> — <code>{ productId, qty, price, discount }</code></p>
</li>
<li><p><strong>API Responses</strong> — Every REST API returns JSON, which is just objects</p>
</li>
<li><p><strong>Config &amp; Settings</strong> — <code>{ theme, language, notifications }</code></p>
</li>
<li><p><strong>React State &amp; Props</strong> — Almost always objects under the hood</p>
</li>
</ul>
<h3>Conclusion</h3>
<p>Objects are the <strong>backbone of JavaScript</strong>. They make your data readable, searchable, and organized. By mastering:</p>
<ul>
<li><p>Key-Value pairs</p>
</li>
<li><p>Dot and Bracket notation</p>
</li>
<li><p>Updating, Adding, Deleting</p>
</li>
<li><p>Nested objects and methods</p>
</li>
<li><p>Looping with <code>for...in</code> and <code>Object.entries()</code></p>
</li>
</ul>
<hr />
<p><em>I write articles on</em> <a href="http://blog.prakashtsx.com"><em>blog.prakashtsx.com</em></a> <em>and also post development-related content on:</em></p>
<ul>
<li><p><a href="https://claude.ai/chat/1564e342-3e7b-40fd-ad95-c9d167001fcd#">Twitter / X</a></p>
</li>
<li><p><a href="https://claude.ai/chat/1564e342-3e7b-40fd-ad95-c9d167001fcd#">LinkedIn</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How Node.js Actually Works]]></title><description><![CDATA[When people start learning Node.js, they often hear statements like:

Node.js is single-threaded

Node.js is non-blocking

Node.js uses an Event Loop


But what actually happens inside Node.js when we]]></description><link>https://blog.prakashtsx.me/node-internal</link><guid isPermaLink="true">https://blog.prakashtsx.me/node-internal</guid><category><![CDATA[Node.js]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Tue, 10 Mar 2026 12:58:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/3b66a6bf-aecd-484d-9f3d-0aed66c03474.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When people start learning <strong>Node.js</strong>, they often hear statements like:</p>
<ul>
<li><p><em>Node.js is single-threaded</em></p>
</li>
<li><p><em>Node.js is non-blocking</em></p>
</li>
<li><p><em>Node.js uses an Event Loop</em></p>
</li>
</ul>
<p>But what actually happens <strong>inside Node.js</strong> when we run a program?</p>
<p>What happens when we execute:</p>
<pre><code class="language-javascript">node index.js
</code></pre>
<p>How does Node.js handle:</p>
<ul>
<li><p>File reading</p>
</li>
<li><p>API calls</p>
</li>
<li><p>Timers</p>
</li>
<li><p>Database queries</p>
</li>
</ul>
<p>while still remaining <strong>fast and scalable</strong>?</p>
<p>To understand this, we must understand <strong>three core components</strong> of Node.js:</p>
<ol>
<li><p><strong>V8 Engine</strong> – executes JavaScript</p>
</li>
<li><p><strong>libuv</strong> – handles asynchronous operations</p>
</li>
<li><p><strong>Event Loop</strong> – coordinates everything</p>
</li>
</ol>
<p>Let’s explore them step by step.</p>
<hr />
<h2>1. What Exactly is Node.js?</h2>
<p>Before diving deeper, we must clear one important confusion.</p>
<p><strong>Node.js is NOT a programming language.</strong></p>
<p>Node.js is a <strong>JavaScript runtime environment</strong>.</p>
<p>This means Node.js provides everything required to <strong>run JavaScript outside the browser</strong>.</p>
<p>A Node.js runtime contains multiple components:</p>
<ul>
<li><p>JavaScript Engine (V8)</p>
</li>
<li><p>Event Loop</p>
</li>
<li><p>libuv threadpool</p>
</li>
<li><p>OS bindings</p>
</li>
<li><p>memory management</p>
</li>
<li><p>networking APIs</p>
</li>
</ul>
<p><strong>In simple terms:</strong></p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/a8a1f73d-8327-4493-87c8-d45dfae08cdb.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h2>2. Understanding Runtime with a Simple Analogy</h2>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/6d9cc033-b10f-4e2c-83a0-1ce93fb22029.png" alt="" style="display:block;margin:0 auto" />

<p>Similarly:</p>
<pre><code class="language-javascript">Your Code → JavaScript

Player → Node.js Runtime
</code></pre>
<p>Node.js provides the <strong>environment required to run JavaScript</strong>.</p>
<hr />
<h2><strong>3. What is a JavaScript Engine?</strong></h2>
<p>A JavaScript engine is a program that executes JavaScript code. Most engines today are built with similar core components:</p>
<ul>
<li><p><strong>Parser</strong>: Transforms source code into an Abstract Syntax Tree (AST)</p>
</li>
<li><p><strong>Interpreter</strong>: Executes the code line-by-line initially</p>
</li>
<li><p><strong>JIT Compiler</strong>: Compiles hot code paths into optimized machine code</p>
</li>
<li><p><strong>Garbage Collector</strong>: Reclaims memory no longer in use</p>
</li>
</ul>
<h3></h3>
<p>❊ <strong>Key JavaScript Engines</strong></p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/bc3aed28-b04d-49b6-a6e6-6d98e3fc8d09.webp" alt="" style="display:block;margin:0 auto" />

<hr />
<h3>4. The V8 Engine – The Heart of Node.js</h3>
<p><em>V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.</em></p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/b260ae38-d7bb-4b7c-be6a-628c1106b26b.png" alt="" style="display:block;margin:0 auto" />

<p>At the core of Node.js lies the <strong>V8 JavaScript Engine</strong>.</p>
<p>V8 was developed by <strong>Google</strong> and is also used in <strong>Chrome</strong>.</p>
<p>Its job is simple:</p>
<blockquote>
<p>Convert JavaScript code into machine code so the computer can execute it.</p>
</blockquote>
<h2>❊ What V8 Actually Does</h2>
<p>V8 performs several critical tasks:</p>
<ul>
<li><p>Parses JavaScript</p>
</li>
<li><p>Compiles JavaScript into machine code</p>
</li>
<li><p>Executes code</p>
</li>
<li><p>Manages memory</p>
</li>
<li><p>Runs garbage collection</p>
</li>
<li><p>Maintains the call stack</p>
</li>
</ul>
<h3><strong>Workflow</strong></h3>
<ol>
<li><p><strong>Parsing</strong>: JavaScript is parsed into an AST.</p>
</li>
<li><p><strong>Ignition (Interpreter)</strong>: Executes unoptimized bytecode quickly.</p>
</li>
<li><p><strong>Turbofan (JIT Compiler)</strong>: Optimizes frequently executed code into fast machine code.</p>
</li>
</ol>
<h3><strong>Example</strong></h3>
<pre><code class="language-javascript">function square(n) {
  return n * n;
}

console.log(square(5)); // 25
</code></pre>
<ul>
<li><p>Initially run by Ignition</p>
</li>
<li><p>Optimized by Turbofan if called repeatedly</p>
</li>
</ul>
<hr />
<h3>5. Call Stack – Where Code Executes</h3>
<p>Inside the V8 engine there is a <strong>Call Stack</strong>.</p>
<p>The call stack keeps track of <strong>which function is currently executing</strong>.</p>
<p>Example:</p>
<pre><code class="language-javascript">function greet() {
  sayHello();
}

function sayHello() {
  console.log("Hello");
}

greet();
</code></pre>
<p>Execution order:</p>
<pre><code class="language-plaintext">Call Stack

 console.log 
 sayHello()  
 greet()     
 global()    
</code></pre>
<p>Functions enter the stack when called and leave after execution.</p>
<p>This is why JavaScript is called <strong>single-threaded execution</strong>.</p>
<p>Only <strong>one function executes at a time</strong> in the call stack.</p>
<hr />
<h3>6. The Problem with Synchronous Code</h3>
<p>Imagine Node.js handled everything synchronously.</p>
<p>Example:</p>
<pre><code class="language-javascript">const fs = require("fs");

const data = fs.readFileSync("bigFile.txt");
console.log(data);
</code></pre>
<p>If the file takes <strong>5 seconds</strong> to read, the entire program stops.</p>
<p>Nothing else runs.</p>
<p>This is called <strong>blocking behavior</strong>.</p>
<p>Node.js solves this problem using <strong>asynchronous architecture</strong>.</p>
<p>And that is where <strong>libuv</strong> comes in.</p>
<hr />
<h3>7. libuv – The Hidden Power of Node.js</h3>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/d16608af-aa36-4f50-96f0-ad63696f9bf5.png" alt="" style="display:block;margin:0 auto" />

<p><strong>libuv</strong> is a C library used internally by Node.js.</p>
<p>Its job is to handle <strong>asynchronous operations</strong>.</p>
<p>Examples:</p>
<ul>
<li><p>File system operations</p>
</li>
<li><p>DNS lookups</p>
</li>
<li><p>compression</p>
</li>
<li><p>cryptography</p>
</li>
<li><p>background tasks</p>
</li>
</ul>
<h3>❊ libuv Threadpool</h3>
<p>libuv provides a <strong>threadpool</strong>.</p>
<p>By default:</p>
<pre><code class="language-plaintext">Threadpool Size = 4 threads
</code></pre>
<p>These threads run <strong>heavy operations in the background</strong>.</p>
<p>Example:</p>
<pre><code class="language-plaintext">Read File
Hash Password
Compress Data
Write File
</code></pre>
<p>These tasks are executed <strong>without blocking the main thread</strong>.</p>
<p>You can even change the threadpool size:</p>
<pre><code class="language-javascript">process.env.UV_THREADPOOL_SIZE = 8;
</code></pre>
<hr />
<h3>8. Event Loop – The Coordinator</h3>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/ac3693b4-ecd8-47f1-a471-412ec067417a.png" alt="" style="display:block;margin:0 auto" />

<p>The <strong>Event Loop</strong> is the central coordinator of Node.js.</p>
<p>It constantly checks:</p>
<pre><code class="language-plaintext">Is the call stack empty?
</code></pre>
<p>If the stack is empty, it pulls tasks from queues and executes them.</p>
<h3>❊ Simple Event Loop Flow</h3>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/84808fe0-fa2f-4071-bd93-152c29a0cd7c.png" alt="" style="display:block;margin:0 auto" />

<p>This loop runs <strong>continuously</strong> while the Node.js process is alive.</p>
<h3>❊ Example to Understand Event Loop</h3>
<pre><code class="language-javascript">console.log("Start");

setTimeout(() =&gt; {
  console.log("Timer finished");
}, 0);

console.log("End");
</code></pre>
<p><em>Output:</em></p>
<pre><code class="language-plaintext">Start
End
Timer finished
</code></pre>
<hr />
<h3>❊ Step-by-Step Execution</h3>
<p>Step 1</p>
<pre><code class="language-javascript">console.log("Start")
</code></pre>
<p>Executed immediately.</p>
<p>Step 2</p>
<pre><code class="language-javascript">setTimeout(...)
</code></pre>
<p>Timer is handled by <strong>libuv timers system</strong>.</p>
<p>Callback waits in queue.</p>
<p>Step 3</p>
<pre><code class="language-javascript">console.log("End")
</code></pre>
<p>Runs immediately.</p>
<p>Step 4</p>
<p>Timer finishes → callback enters queue.</p>
<p>Step 5</p>
<p>Event loop pushes callback to stack.</p>
<pre><code class="language-javascript">Timer finished
</code></pre>
<h3>❊ Event Loop Phases (Advanced)</h3>
<p>Node.js Event Loop has multiple phases.</p>
<p>Order:</p>
<pre><code class="language-plaintext">1 Timers
2 Pending Callbacks
3 Idle / Prepare
4 Poll
5 Check
6 Close Callbacks
</code></pre>
<p>Examples:</p>
<pre><code class="language-plaintext">setTimeout → Timers phase
I/O callbacks → Poll phase
setImmediate → Check phase
</code></pre>
<p>This is how Node.js schedules asynchronous work efficiently.</p>
<h3>❊ Complete Node.js Architecture</h3>
<p>Here is the complete flow:</p>
<pre><code class="language-plaintext">Your JavaScript Code
        ↓
V8 Engine executes synchronous code
        ↓
Async operations detected
        ↓
libuv handles background tasks
        ↓
Callbacks added to queues
        ↓
Event Loop picks them
        ↓
Callback executed by V8
</code></pre>
<hr />
<h3>❊ Real-World Analogy (Restaurant System)</h3>
<p>Imagine a restaurant.</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/342ddea9-01ae-40d5-8d27-79da034964a5.png" alt="" style="display:block;margin:0 auto" />

<p>Actors:</p>
<pre><code class="language-plaintext">Restaurant → Node.js Runtime
Waiter → Event Loop
Manager → V8 Engine
Chefs → libuv Threadpool
Customers → Users
Food Orders → JavaScript Tasks
</code></pre>
<p>Workflow:</p>
<p>1️⃣ Customer places order  </p>
<p>2️⃣ Waiter forwards order to chefs  </p>
<p>3️⃣ Chefs cook food in kitchen  </p>
<p>4️⃣ Waiter serves when ready</p>
<p>The waiter <strong>never cooks</strong>.</p>
<p>Similarly:</p>
<pre><code class="language-plaintext">Event Loop does NOT execute code
V8 executes the code
</code></pre>
<p>The event loop simply <strong>manages tasks</strong>.</p>
<hr />
<h3>❊ Conclusion</h3>
<p>Whenever you run Node.js, remember this pipeline:</p>
<pre><code class="language-plaintext">JavaScript Code
       ↓
V8 Engine executes code
       ↓
Async tasks sent to libuv
       ↓
Callbacks stored in queues
       ↓
Event Loop pushes callbacks
       ↓
V8 executes them
</code></pre>
<p>This architecture is the reason Node.js can handle <strong>thousands of concurrent connections efficiently</strong>.</p>
<hr />
<h3><strong>❊ Want More…?</strong></h3>
<p>I write articles on <a href="http://blog.prakashtsx.com"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Understanding Object-Oriented Programming in JavaScript]]></title><description><![CDATA[⤑ Object-Oriented Programming (OOP) is a programming paradigm used to structure code in a way that models real-world entities.
Instead of writing scattered functions and variables, OOP helps us organi]]></description><link>https://blog.prakashtsx.me/js-oops</link><guid isPermaLink="true">https://blog.prakashtsx.me/js-oops</guid><category><![CDATA[OOPS]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Tue, 10 Mar 2026 04:59:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/0c30d2b7-a40e-417e-be9c-00b0e72425ca.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>⤑ Object-Oriented Programming (OOP) is a programming paradigm used to structure code in a way that models real-world entities.</p>
<p>Instead of writing scattered functions and variables, OOP helps us organize code into <strong>objects and classes</strong>.</p>
<p>JavaScript supports OOP concepts, making code more <strong>reusable, modular, and easier to maintain</strong>.</p>
<img src="https://media.geeksforgeeks.org/wp-content/uploads/20250722184505270450/Types-of-OOPS-2.gif" alt="" style="display:block;margin:0 auto" />

<hr />
<h2>❊ What is Object-Oriented Programming?</h2>
<p>⤑ Object-Oriented Programming is a way of writing code where we create <strong>objects that represent real-world entities</strong>.</p>
<p>These objects contain:</p>
<p>• <strong>Properties</strong> → data about the object<br />• <strong>Methods</strong> → actions the object can perform</p>
<h3>❊ Example: Car Object</h3>
<p>Instead of listing properties and methods separately, we can visualize a <strong>Car object</strong> that contains both <strong>data (properties)</strong> and <strong>behavior (methods)</strong>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/49fd8e14-b4cf-4198-a968-206336e82fd1.png" alt="" style="display:block;margin:0 auto" />

<p>In this example, the <strong>Car object</strong> has:</p>
<p><strong>Properties (data)</strong><br />• brand<br />• color<br />• speed</p>
<p><strong>Methods (behavior)</strong><br />• start()<br />• stop()<br />• accelerate()</p>
<p>Instead of writing separate variables and functions, Object-Oriented Programming groups them together inside a single <strong>object</strong>.</p>
<hr />
<h2>❊ Real World Analogy: Blueprint → Objects</h2>
<p>Think of a <strong>class as a blueprint</strong>.</p>
<p>Example:</p>
<p>Blueprint → Car Design<br />Object → Actual Car</p>
<p>One blueprint can create <strong>many cars</strong>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/7ff788f3-0256-4a8f-af58-b4eeff4594f9.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h2>❊ What is a Class in JavaScript?</h2>
<p>⤑ A <strong>class</strong> is a template used to create objects.</p>
<p>It defines the <strong>properties and methods</strong> that objects will have.</p>
<p>Example:</p>
<pre><code class="language-javascript">class Car {
  constructor(brand, color) {
    this.brand = brand;
    this.color = color;
  }

  start() {
    console.log(this.brand + " car started");
  }
}
</code></pre>
<p>Here:</p>
<p><em><strong>Car → class<br />brand, color → properties<br />start() → method</strong></em></p>
<hr />
<h2>❊ Creating Objects from a Class</h2>
<p>⤑ Once we define a class, we can create objects using the <strong>new keyword</strong>.</p>
<p>Example:</p>
<pre><code class="language-javascript">const car1 = new Car("Toyota", "Red");
const car2 = new Car("BMW", "Black");

car1.start();
car2.start();
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">Toyota car started
BMW car started
</code></pre>
<p>Each object has its <strong>own data</strong> but shares the same structure.</p>
<hr />
<h2>❊ Constructor Method</h2>
<p>⤑ The <strong>constructor()</strong> method is a special method used to initialize object properties.</p>
<p>It automatically runs when a new object is created.</p>
<p>Example:</p>
<pre><code class="language-javascript">class Person {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }
}

const p1 = new Person("Rahul", 22);
console.log(p1.name);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">Rahul
</code></pre>
<p>The constructor helps us assign values when creating objects.</p>
<hr />
<h2>❊ Methods Inside a Class</h2>
<p>⤑ Methods define the <strong>behavior of objects</strong>.</p>
<p>Example:</p>
<pre><code class="language-javascript">class Dog {
  constructor(name) {
    this.name = name;
  }

  bark() {
    console.log(this.name + " is barking");
  }
}

const dog1 = new Dog("Rocky");
dog1.bark();
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">Rocky is barking
</code></pre>
<p>Methods allow objects to <strong>perform actions</strong>.</p>
<hr />
<h2>❊ Basic Idea of Encapsulation</h2>
<p>⤑ Encapsulation means <strong>bundling data and methods together inside a class</strong>.</p>
<p>It helps protect data and organize code.</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/e878a4df-4a43-4ea6-9d86-5803818149ad.png" alt="" style="display:block;margin:0 auto" />

<p>Example:</p>
<pre><code class="language-javascript">class BankAccount {
  constructor(balance) {
    this.balance = balance;
  }

  deposit(amount) {
    this.balance += amount;
  }

  getBalance() {
    return this.balance;
  }
}
</code></pre>
<p>Here:</p>
<p><em><strong>balance → data<br />deposit() → modifies data<br />getBalance() → accesses data</strong></em></p>
<p>All related functionality is inside the class.</p>
<hr />
<h2>❊ Why Use Object-Oriented Programming?</h2>
<p>OOP helps developers:</p>
<p>• Organize code better<br />• Reuse code easily<br />• Reduce duplication<br />• Model real-world systems<br />• Maintain large applications</p>
<p>Many modern frameworks and applications rely on OOP concepts.</p>
<hr />
<h2>❊ Conclusion</h2>
<p>⤑ Object-Oriented Programming is an important concept in JavaScript that helps structure code effectively.</p>
<p>In this blog we learned:</p>
<p>• What Object-Oriented Programming means<br />• Blueprint → Object analogy<br />• What classes are in JavaScript<br />• Creating objects using classes<br />• Constructor methods<br />• Methods inside classes<br />• Basic idea of encapsulation</p>
<p>Understanding OOP will help you write <strong>clean, scalable, and maintainable JavaScript applications</strong>.</p>
<hr />
<h3><strong>❊ Want More…?</strong></h3>
<p>I write articles on <a href="http://blog.prakashtsx.com"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Control Flow in Programming (JavaScript)]]></title><description><![CDATA[1. Introduction: What is Control Flow in Programming?
Imagine a normal day in your life.
You wake up and think:

If it is morning, I will brush my teeth

If it is Sunday, I will rest

If it is Monday,]]></description><link>https://blog.prakashtsx.me/control-flow</link><guid isPermaLink="true">https://blog.prakashtsx.me/control-flow</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[control flow]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Fri, 06 Mar 2026 18:03:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/79869680-c044-455b-91a8-d60163fc8f99.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>1. Introduction: What is Control Flow in Programming?</h2>
<p>Imagine a normal day in your life.</p>
<p>You wake up and think:</p>
<ul>
<li><p>If it is <strong>morning</strong>, I will <strong>brush my teeth</strong></p>
</li>
<li><p>If it is <strong>Sunday</strong>, I will <strong>rest</strong></p>
</li>
<li><p>If it is <strong>Monday</strong>, I will <strong>go to work</strong></p>
</li>
</ul>
<p>Your brain is constantly making <strong>decisions</strong>.</p>
<p>Programming works the same way.</p>
<p>A computer program also needs to decide:</p>
<ul>
<li><p>Should this code run?</p>
</li>
<li><p>Or should another code run?</p>
</li>
<li><p>Or should it skip something?</p>
</li>
</ul>
<p>This process is called <strong>Control Flow</strong>.</p>
<h3>Definition</h3>
<p><strong>Control Flow determines the order in which instructions are executed in a program.</strong></p>
<p>Without control flow, a program would execute every line from top to bottom with no decision-making.</p>
<h2>❊Example Without Control Flow</h2>
<pre><code class="language-javascript">console.log("Wake up");
console.log("Go to gym");
console.log("Go to office");
console.log("Sleep");
</code></pre>
<p>The program will run every line.</p>
<p>But what if today is <strong>Sunday</strong>?</p>
<p>You might not want to go to the office.</p>
<p>This is where <strong>control flow statements</strong> come into play.</p>
<h2>❊ Types of Control Flow Statements</h2>
<p>The most common ones are:</p>
<ol>
<li><p><strong>if statement</strong></p>
</li>
<li><p><strong>if-else statement</strong></p>
</li>
<li><p><strong>else-if ladder</strong></p>
</li>
<li><p><strong>switch statement</strong></p>
</li>
</ol>
<p>These help programs <strong>make decisions</strong>.</p>
<h2>2. The if Statement</h2>
<p>The <strong>if statement</strong> executes code <strong>only if a condition is true</strong>.</p>
<h3>Syntax</h3>
<pre><code class="language-javascript">if (condition) {
    // code runs if condition is true
}
</code></pre>
<h2>❊ Real Life Example</h2>
<p>Imagine a school rule:</p>
<blockquote>
<p>If a student’s marks are greater than 40, they pass.</p>
</blockquote>
<pre><code class="language-javascript">let marks = 50;

if (marks &gt; 40) {
  console.log("You passed the exam");
}
</code></pre>
<h3>Step-by-Step Execution</h3>
<ol>
<li><p>Program reads the value of <code>marks</code></p>
</li>
<li><p>It checks the condition <code>marks &gt; 40</code></p>
</li>
<li><p>If the condition is <strong>true</strong>, the code inside <code>{}</code> runs</p>
</li>
<li><p>If the condition is <strong>false</strong>, the program skips it</p>
</li>
</ol>
<h3>Example Output</h3>
<pre><code class="language-javascript">You passed the exam
</code></pre>
<h3>When the condition is false</h3>
<pre><code class="language-javascript">let marks = 30;

if (marks &gt; 40) {
  console.log("You passed");
}
</code></pre>
<p><em>Output:</em></p>
<pre><code class="language-javascript">(no output)
</code></pre>
<p>Because the condition is <strong>false</strong>.</p>
<h2>3. The if-else Statement</h2>
<p>Sometimes we want the program to do <strong>something else</strong> if the condition is false.</p>
<p>That is where <strong>if-else</strong> is used.</p>
<h3>Syntax</h3>
<pre><code class="language-javascript">if (condition) {
   // runs if condition is true
} else {
   // runs if condition is false
}
</code></pre>
<h2>❊ Real Life Example</h2>
<p>At a movie theatre:</p>
<ul>
<li><p>If <strong>age ≥ 18</strong> → Allowed</p>
</li>
<li><p>Else → Not allowed</p>
</li>
</ul>
<h3>Example</h3>
<pre><code class="language-javascript">let age = 16;

if (age &gt;= 18) {
  console.log("You can watch the movie");
} else {
  console.log("You are not allowed");
}
</code></pre>
<h3>❊ Step-by-Step Execution</h3>
<ol>
<li><p>Program checks <code>age &gt;= 18</code></p>
</li>
<li><p>If true → first block runs</p>
</li>
<li><p>If false → <code>else</code> block runs</p>
</li>
</ol>
<h3>Output</h3>
<pre><code class="language-javascript">You are not allowed
</code></pre>
<h2>4. The Else If Ladder</h2>
<p>Sometimes there are <strong>multiple conditions</strong>.</p>
<p>Example: grading system</p>
<table>
<thead>
<tr>
<th>Marks</th>
<th>Grade</th>
</tr>
</thead>
<tbody><tr>
<td>90+</td>
<td>A</td>
</tr>
<tr>
<td>75+</td>
<td>B</td>
</tr>
<tr>
<td>50+</td>
<td>C</td>
</tr>
<tr>
<td>&lt;50</td>
<td>Fail</td>
</tr>
</tbody></table>
<p>This is where <strong>else-if ladder</strong> is useful.</p>
<h3>Syntax</h3>
<pre><code class="language-javascript">if (condition1) {

} else if (condition2) {

} else if (condition3) {

} else {

}
</code></pre>
<h3>Example</h3>
<pre><code class="language-javascript">let marks = 82;

if (marks &gt;= 90) {
  console.log("Grade A");
} 
else if (marks &gt;= 75) {
  console.log("Grade B");
}
else if (marks &gt;= 50) {
  console.log("Grade C");
}
else {
  console.log("Fail");
}
</code></pre>
<h3>⤑ Step-by-Step Execution</h3>
<p>Marks = <strong>82</strong></p>
<ol>
<li><p>Check <code>marks &gt;= 90</code> → false</p>
</li>
<li><p>Check <code>marks &gt;= 75</code> → true</p>
</li>
<li><p>Program prints <strong>Grade B</strong></p>
</li>
<li><p>Remaining conditions are skipped</p>
</li>
</ol>
<h3><em>Output</em></h3>
<pre><code class="language-plaintext">Grade B
</code></pre>
<h2>5. The Switch Statement</h2>
<p>The <strong>switch statement</strong> is used when there are <strong>many possible fixed values</strong>.</p>
<p>It is commonly used for:</p>
<ul>
<li><p>menus</p>
</li>
<li><p>days of week</p>
</li>
<li><p>months</p>
</li>
<li><p>options</p>
</li>
</ul>
<h3>⤑ Syntax</h3>
<pre><code class="language-javascript">switch(expression) {

  case value1:
    code
    break;

  case value2:
    code
    break;

  default:
    code
}
</code></pre>
<h3>⤑ <em>Example: Day of Week</em></h3>
<pre><code class="language-javascript">let day = 3;

switch(day) {

  case 1:
    console.log("Monday");
    break;

  case 2:
    console.log("Tuesday");
    break;

  case 3:
    console.log("Wednesday");
    break;

  default:
    console.log("Invalid day");
}
</code></pre>
<h3>⤑ Step-by-Step Execution</h3>
<ol>
<li><p><code>day = 3</code></p>
</li>
<li><p>Switch checks cases</p>
</li>
<li><p><code>case 3</code> matches</p>
</li>
<li><p>Prints <strong>Wednesday</strong></p>
</li>
</ol>
<h2>❊ Understanding break in Switch</h2>
<p><code>break</code> stops execution.</p>
<p>Without break, the program continues executing the next cases.</p>
<h3>⤑ Example Without break</h3>
<pre><code class="language-javascript">let day = 2;

switch(day) {

  case 1:
    console.log("Monday");

  case 2:
    console.log("Tuesday");

  case 3:
    console.log("Wednesday");
}
</code></pre>
<h3><em>Output</em></h3>
<pre><code class="language-plaintext">Tuesday
Wednesday
</code></pre>
<p>This happens because <strong>there is no break</strong>.</p>
<h2>6. When to Use Switch vs If-Else</h2>
<h3>⤑ Use if-else when:</h3>
<ul>
<li>conditions are <strong>ranges</strong></li>
</ul>
<p>Example:</p>
<pre><code class="language-javascript">marks &gt; 90
age &gt;= 18
temperature &gt; 30
</code></pre>
<h3>⤑ Use switch when:</h3>
<ul>
<li>checking <strong>specific values</strong></li>
</ul>
<p>Example:</p>
<pre><code class="language-javascript">day = Monday
role = admin
menu option = 1
</code></pre>
<h3>⤑ Example</h3>
<p>Good for <strong>if-else</strong></p>
<pre><code class="language-javascript">if (marks &gt; 90)
</code></pre>
<p>Good for <strong>switch</strong></p>
<pre><code class="language-javascript">switch(day)
</code></pre>
<h2>❊ Comparison Table</h2>
<table>
<thead>
<tr>
<th>Feature</th>
<th>if-else</th>
<th>switch</th>
</tr>
</thead>
<tbody><tr>
<td>Range conditions</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Exact values</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Readability with many cases</td>
<td>Hard</td>
<td>Easier</td>
</tr>
<tr>
<td>Common use</td>
<td>logic</td>
<td>menus/options</td>
</tr>
</tbody></table>
<h2>❊ Conclusion</h2>
<p>Control flow is one of the <strong>most fundamental concepts in programming</strong>.</p>
<p>It allows programs to:</p>
<ul>
<li><p>make decisions</p>
</li>
<li><p>run different code paths</p>
</li>
<li><p>handle real-world logic</p>
</li>
</ul>
<p>The most important control flow statements are:</p>
<ul>
<li><p><strong>if</strong></p>
</li>
<li><p><strong>if-else</strong></p>
</li>
<li><p><strong>else-if ladder</strong></p>
</li>
<li><p><strong>switch</strong></p>
</li>
</ul>
<p>Understanding when to use each of them will make your programs <strong>cleaner and easier to understand</strong>.</p>
<hr />
<h3>❊ <strong>Want More…?</strong></h3>
<p>I write articles on <a href="http://blog.prakashtsx.com"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[JavaScript Promise Methods]]></title><description><![CDATA[Welcome to the world of JavaScript! If you have ever promised a friend you would call them back, you already understand the logic of a Promise.
In programming, things often take time like downloading ]]></description><link>https://blog.prakashtsx.me/promises-methods</link><guid isPermaLink="true">https://blog.prakashtsx.me/promises-methods</guid><category><![CDATA[promises]]></category><category><![CDATA[promise methods]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Sun, 01 Mar 2026 09:43:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/0d8ecbd8-9d58-46ce-bfff-43cbcefa9454.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome to the world of JavaScript! If you have ever promised a friend you would call them back, you already understand the logic of a <strong>Promise</strong>.</p>
<p>In programming, things often take time like downloading a large image or fetching data from a server. Instead of making the whole program wait and freeze, JavaScript uses "Promises" to manage these tasks.</p>
<hr />
<h2><strong>1. What is a Promise?</strong></h2>
<p>⤑ Imagine <strong>Jethalal</strong> wants to impress <strong>Babita Ji</strong> by bringing her a special "Chocolate Gunda" from Ahmedabad.</p>
<ul>
<li><p><strong>The Promise:</strong> Jethalal tells Babita Ji, "I will bring you the sweets by evening."</p>
</li>
<li><p><strong>The Wait:</strong> Babita Ji doesn't know yet if she will get the sweets or if Jethalal will forget. She just has his "Promise."</p>
</li>
</ul>
<p>⤑ In JavaScript, a <strong>Promise</strong> is an object representing the eventual completion (or failure) of an asynchronous operation and its resulting value.</p>
<h2>2. The Three States of a Promise</h2>
<p>⤑ Just like Jethalal’s commitment, every Promise goes through three stages:</p>
<ol>
<li><p><strong>Pending:</strong> Jethalal is currently on his way. The result is unknown.</p>
</li>
<li><p><strong>Fulfilled (Resolved):</strong> Jethalal arrives with the sweets! Babita Ji is happy.</p>
</li>
<li><p><strong>Rejected:</strong> Jethalal gets stuck in a traffic jam or Bagha forgets to order them. Babita Ji is disappointed.</p>
</li>
</ol>
<h2>3. The Basic Methods: Handling One Promise</h2>
<p>⤑ When you have a single promise, you use these three methods to handle the result.</p>
<h3><code>then()</code> – The Success Story</h3>
<p>⤑ If Jethalal successfully brings the sweets, what should Babita Ji do? She handles the success using <code>.then()</code>.</p>
<pre><code class="language-javascript">myPromise.then((message) =&gt; {
  console.log("Success: " + message);
});
</code></pre>
<p>⤑ This code says, "If the promise is fulfilled, take the result and do something with it."</p>
<h3><code>catch()</code> – The Backup Plan</h3>
<p>⤑ If Jethalal fails (the promise is rejected), Babita Ji needs to handle the error. She uses <code>.catch()</code>.</p>
<pre><code class="language-javascript">myPromise.catch((error) =&gt; {
  console.log("Error: " + error);
});
</code></pre>
<p>⤑ This code says, "If something goes wrong, tell me what the error is so I can fix it."</p>
<h3><code>finally()</code> – The Final Word</h3>
<p>⤑ Whether Jethalal brings the sweets or fails, <strong>Bapuji</strong> will definitely give him a lecture. This happens no matter what.</p>
<pre><code class="language-javascript">myPromise.finally(() =&gt; {
  console.log("Process finished. Bapuji starts his lecture.");
});
</code></pre>
<p>⤑ This code runs at the very end, regardless of whether the promise succeeded or failed.</p>
<hr />
<h2>4. Handling Multiple Promises (Static Methods)</h2>
<p>⤑ Sometimes, we have many promises happening at once. This is where things get interesting in Gokuldham!</p>
<h3><code>Promise.all()</code> – The Team Player</h3>
<p>⤑ <strong>Scenario:</strong> Tapu Sena (Tapu, Sonu, Goli) decides to clean the clubhouse.</p>
<ul>
<li><p>If <strong>all</strong> of them finish their work, the party starts.</p>
</li>
<li><p>If even <strong>one</strong> person fails, the whole plan is cancelled.</p>
</li>
</ul>
<pre><code class="language-javascript">Promise.all([promiseTapu, promiseSonu, promiseGoli])
  .then((results) =&gt; console.log("Clubhouse is clean!"))
  .catch((err) =&gt; console.log("Someone failed, party cancelled!"));
</code></pre>
<p>⤑ It waits for <strong>all</strong> to succeed. If one fails, the whole thing fails immediately.</p>
<h3><code>Promise.allSettled()</code> – The Report Card</h3>
<p>⤑ <strong>Scenario:</strong> Bhide gives different tasks to everyone for Ganpati Festival.</p>
<ul>
<li><p>Bhide wants a report of who finished and who failed.</p>
</li>
<li><p>He doesn't stop the festival if one person fails; he just wants to know the status of <strong>everyone</strong>.</p>
</li>
</ul>
<pre><code class="language-javascript">Promise.allSettled([task1, task2, task3])
  .then((results) =&gt; console.log("Here is the status of every task."));
</code></pre>
<p>⤑ <strong>Behavior:</strong> It waits for all promises to finish (either success or failure) and returns an array of results.</p>
<h3><code>Promise.race()</code> – The Fast and Curious</h3>
<p>⤑ <strong>Scenario:</strong> Jethalal, Bhide, and Iyer are all racing to reach the Soda Shop first to talk to Abdul.</p>
<ul>
<li><p>The person who reaches <strong>first</strong> wins.</p>
</li>
<li><p>It doesn't matter if they succeeded or failed; the first one to "cross the finish line" (settle) wins.</p>
</li>
</ul>
<pre><code class="language-javascript">Promise.race([jethaRun, bhideRun, iyerRun])
  .then((winner) =&gt; console.log("The first person reached!"));
</code></pre>
<p>⤑ <strong>Behavior:</strong> It returns the result of the <strong>first</strong> promise that finishes, whether it's a success or an error.</p>
<h3><code>Promise.any()</code> – The First Success</h3>
<p>⤑ <strong>Scenario:</strong> Popatlal is looking for a marriage proposal. He sends his profile to three different matchmakers.</p>
<ul>
<li><p>He only cares about the <strong>first one who says "Yes!"</strong> (success).</p>
</li>
<li><p>If the first one says "No," he waits for the second one.</p>
</li>
<li><p>He only gets sad if <strong>everyone</strong> says "No."</p>
</li>
</ul>
<pre><code class="language-javascript">Promise.any([matchMaker1, matchMaker2, matchMaker3])
  .then((firstYes) =&gt; console.log("Popatlal is getting married!"))
  .catch((err) =&gt; console.log("All rejected. Cancel the umbrella."));
</code></pre>
<p>⤑ <strong>Behavior:</strong> It waits for the <strong>first successful</strong> promise. It only fails if every single promise fails.</p>
<hr />
<h2>❊ Table :</h2>
<table style="min-width:390px"><colgroup><col style="width:365px"></col><col style="min-width:25px"></col></colgroup><tbody><tr><td><p><strong><em>Method</em></strong></p></td><td><p><strong><em>Behavior</em></strong></p></td></tr><tr><td><p><strong>.then()</strong></p></td><td><p>Runs when a promise succeeds.</p></td></tr><tr><td><p><strong>.catch()</strong></p></td><td><p>Runs when a promise fails.</p></td></tr><tr><td><p><strong>.finally()</strong></p></td><td><p>Runs always, regardless of success or failure.</p></td></tr><tr><td><p><strong>Promise.all()</strong></p></td><td><p>Succeeds if <strong>all</strong> succeed; fails if <strong>any</strong> fail.</p></td></tr><tr><td><p><strong>Promise.allSettled()</strong></p></td><td><p>Waits for <strong>all</strong> to finish, no matter the outcome.</p></td></tr><tr><td><p><strong>Promise.race()</strong></p></td><td><p>Returns the <strong>first</strong> promise to finish (win or lose).</p></td></tr><tr><td><p><strong>Promise.any()</strong></p></td><td><p>Returns the <strong>first success</strong>; fails only if <strong>all</strong> fail.</p></td></tr></tbody></table>

<hr />
<h2>❊ Conclusion</h2>
<p>JavaScript Promises are just like the commitments made in Gokuldham Society. They help us manage time, handle failures gracefully, and coordinate between different tasks. Just remember: keep your promises like Jethalal tries to (mostly) and handle your errors like Bhide handles his "Zamana!"</p>
<hr />
<h3><strong>Want More…?</strong></h3>
<p>I write articles on <a href="http://blog.prakashtsx.com"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Arrow Functions in JavaScript: A Simpler Way to Write Functions]]></title><description><![CDATA[Modern JavaScript introduced arrow functions to make writing functions shorter and cleaner.
If you're learning JS, arrow functions will quickly become your favorite feature.
Let’s understand them step]]></description><link>https://blog.prakashtsx.me/arrow-function</link><guid isPermaLink="true">https://blog.prakashtsx.me/arrow-function</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Thu, 26 Feb 2026 18:53:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/1f90a1dc-e61c-433c-a5af-9d4ed1d578e0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Modern JavaScript introduced <strong>arrow functions</strong> to make writing functions shorter and cleaner.</p>
<p>If you're learning JS, arrow functions will quickly become your favorite feature.</p>
<p>Let’s understand them step by step.</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/a04622bf-893d-432f-add6-b1692ba317f5.png" alt="" style="display:block;margin:0 auto" />

<h2>❋ What Are Arrow Functions?</h2>
<p>Arrow functions are a <strong>shorter way to write functions</strong> in JavaScript.</p>
<p>They were introduced in ES6 (2015) to reduce boilerplate code and improve readability.</p>
<p>Instead of writing:</p>
<pre><code class="language-javascript">function greet(name) {
  return "Hello " + name;
}
</code></pre>
<p>We can write:</p>
<pre><code class="language-javascript">const greet = (name) =&gt; {
  return "Hello " + name;
};
</code></pre>
<h2>❋ Basic Arrow Function Syntax</h2>
<p>Here is the general syntax:</p>
<pre><code class="language-javascript">const functionName = (parameters) =&gt; {
  // code
};
</code></pre>
<ul>
<li><p><code>const</code> → storing function in a variable</p>
</li>
<li><p><code>(parameters)</code> → input values</p>
</li>
<li><p><code>=&gt;</code> → arrow symbol</p>
</li>
<li><p><code>{}</code> → function body</p>
</li>
</ul>
<hr />
<h2>❋ Arrow Function with One Parameter</h2>
<p>If there is <strong>only one parameter</strong>, you can remove parentheses.</p>
<p>Normal function:</p>
<pre><code class="language-javascript">function square(num) {
  return num * num;
}
</code></pre>
<p>Arrow function:</p>
<pre><code class="language-javascript">const square = num =&gt; {
  return num * num;
};
</code></pre>
<h2>❋ Arrow Function with Multiple Parameters</h2>
<p>If there are multiple parameters, parentheses are required.</p>
<pre><code class="language-javascript">const add = (a, b) =&gt; {
  return a + b;
};
</code></pre>
<p>Example:</p>
<pre><code class="language-javascript">console.log(add(5, 3)); // 8
</code></pre>
<hr />
<h2>❋ Implicit Return vs Explicit Return</h2>
<p>This is the most powerful feature.</p>
<h3>🔹 Explicit Return (using return keyword)</h3>
<pre><code class="language-javascript">const multiply = (a, b) =&gt; {
  return a * b;
};
</code></pre>
<h3>🔹 Implicit Return (no return keyword)</h3>
<p>If your function has <strong>only one expression</strong>, you can remove <code>{}</code> and <code>return</code>.</p>
<pre><code class="language-javascript">const multiply = (a, b) =&gt; a * b;
</code></pre>
<p>JavaScript automatically returns the value.</p>
<p>That’s called <strong>implicit return</strong>.</p>
<hr />
<h2>❋ Basic Difference: Normal Function vs Arrow Function</h2>
<table>
<thead>
<tr>
<th>Feature</th>
<th>Normal Function</th>
<th>Arrow Function</th>
</tr>
</thead>
<tbody><tr>
<td>Syntax</td>
<td>Longer</td>
<td>Shorter</td>
</tr>
<tr>
<td><code>this</code> behavior</td>
<td>Has its own <code>this</code></td>
<td>Uses parent <code>this</code></td>
</tr>
<tr>
<td>Hoisting</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Beginner friendly</td>
<td>Yes</td>
<td>Yes</td>
</tr>
</tbody></table>
<h2>❋ Why Arrow Functions Matter</h2>
<ul>
<li><p>Less boilerplate</p>
</li>
<li><p>Cleaner callbacks</p>
</li>
<li><p>Perfect for array methods like:</p>
<ul>
<li><p><code>map()</code></p>
</li>
<li><p><code>filter()</code></p>
</li>
<li><p><code>reduce()</code></p>
</li>
</ul>
</li>
<li><p>Modern JavaScript standard</p>
</li>
</ul>
<hr />
<h3><strong>Want More…?</strong></h3>
<p>I write articles on <a href="http://blog.prakashtsx.com"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Array Methods You Must Know]]></title><description><![CDATA[If you want to become good at JavaScript especially as a web developer arrays are everywhere.

API data comes in arrays

Database results come in arrays

UI lists are rendered from arrays


If you mas]]></description><link>https://blog.prakashtsx.me/array-methods</link><guid isPermaLink="true">https://blog.prakashtsx.me/array-methods</guid><category><![CDATA[array methods]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Wed, 25 Feb 2026 10:40:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/c3eba613-cf12-4fff-bb62-157b90c0cb2c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you want to become good at JavaScript especially as a web developer <strong>arrays</strong> are everywhere.</p>
<ul>
<li><p>API data comes in arrays</p>
</li>
<li><p>Database results come in arrays</p>
</li>
<li><p>UI lists are rendered from arrays</p>
</li>
</ul>
<p>If you master array methods, your code becomes:</p>
<ul>
<li><p>Cleaner</p>
</li>
<li><p>Shorter</p>
</li>
<li><p>More readable</p>
</li>
<li><p>More professional</p>
</li>
</ul>
<p>Let’s understand the most important ones.</p>
<hr />
<h3><code>push()</code></h3>
<p>This method adds new element(s) to the end of the attached JavaScript array, changing the original array, and returns the new length of the array. This method accepts the elements you wish to add at the end of the array as parameters.</p>
<pre><code class="language-javascript">myArray.push(element1, element2, ..., elementX);
</code></pre>
<p>Let’s now create a new array then add some more fruits using the <code>push()</code> method:</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/a4fb1ba0-ed63-4148-aec0-89cd87a55264.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h3><code>pop()</code></h3>
<p>This method removes the last element of the attached JavaScript array, altering the original array, and returns the removed element.</p>
<pre><code class="language-javascript">myArray.pop();
</code></pre>
<p><strong>Note</strong> : You don’t pass anything as a parameter to the <code>pop()</code> method.</p>
<p>Here’s an example showing how to use the <code>pop()</code> method:</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/b76a738e-ce1b-46d7-9dfb-fd8d97a35841.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h3><code>shift()</code></h3>
<p>The <code>shift()</code> method removes the first element of an array. It works similarly to the <code>pop()</code> method, but instead of removing from the end, it removes from the beginning of the attached array. It returns the removed/shifted element.</p>
<pre><code class="language-javascript">myArray.shift();
</code></pre>
<p>Let’s now create a new array of animal names and then learn how to use the <code>shift()</code> method to remove the first name from the array:</p>
<hr />
<h3><code>unshift()</code></h3>
<p>The <code>unshift()</code> method works similarly to the <code>push()</code> method as it is used to add new elements to an array, but to the beginning of an array. This method takes the element(s) you wish to add at the beginning of the array as parameters. It also returns the new length of the array.</p>
<pre><code class="language-javascript">myArray.unshift(element1, element2, ..., elementX);
</code></pre>
<p>Let’s now create a new array of food names and then add more food names to the array using the <code>unshift()</code> method:</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/b3e48eca-6f8a-47e4-823c-51df3dec5331.png" alt="" style="display:block;margin:0 auto" />

<hr />
<p>❋ <strong>Map, reduce, and filter</strong> are all array methods in JavaScript. Each one will iterate over an array and perform a transformation or computation. Each will return a new array based on the result of the function.</p>
<p>Let's Understand these concepts :</p>
<h2>✤ <strong>Map</strong></h2>
<p><code>map()</code> creates a <strong>new array</strong> by transforming each element.</p>
<p>⤑ It does NOT modify the original array.</p>
<h3><strong>Syntax</strong></h3>
<pre><code class="language-javascript">var new_array = arr.map(function callback(element, index, array) {
    // Return value for new_array
}[, thisArg])
</code></pre>
<p>In the callback, only the array <code>element</code> is required. Usually some action is performed on the value and then a new value is returned.</p>
<h2>Traditional For Loop vs map()</h2>
<h3>🔸 Using For Loop</h3>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/a57a4830-7646-4a98-91ee-fba16ed06254.png" alt="" style="display:block;margin:0 auto" />

<h3>🔸 Using map()</h3>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/c6cccebe-62a9-48ea-bddc-3f85903ad78a.png" alt="" style="display:block;margin:0 auto" />

<p>So basically the map function <strong>maps each every value</strong> in the array and transforms it based on a given condition.</p>
<hr />
<h2>✤ Filter()</h2>
<p>The <code>filter()</code> method takes each element in an array and it applies a conditional statement against it. If this conditional returns true, the element gets pushed to the output array. If the condition returns false, the element does not get pushed to the output array.</p>
<h3><strong>Syntax</strong></h3>
<pre><code class="language-javascript">var new_array = arr.filter(function callback(element, index, array) {
    // Return true or false
}[, thisArg])
</code></pre>
<p>The syntax for <code>filter</code> is similar to <code>map</code>, except the callback function should return <code>true</code> to keep the element, or <code>false</code> otherwise. In the callback, only the <code>element</code> is required.</p>
<h3><strong>Examples</strong></h3>
<p>In the following example, odd numbers are "filtered" out, leaving only even numbers.</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/23ee1f13-3520-44d6-ad17-0fcd3f56beb7.png" alt="" style="display:block;margin:0 auto" />

<p>In the next example, <code>filter()</code> is used to get all the students whose grades are greater than or equal to 90.</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/213f185f-09cc-499e-a943-c01becb1fafd.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h2>✤ Reduce()</h2>
<p>The <code>reduce()</code> method reduces an array of values down to just one value. To get the output value, it runs a reducer function on each element of the array.</p>
<h3><strong>Syntax</strong></h3>
<pre><code class="language-javascript">arr.reduce(callback[, initialValue])
</code></pre>
<p>The <code>callback</code> argument is a function that will be called once for every item in the array. This function takes four arguments, but often only the first two are used.</p>
<ul>
<li><p><em>accumulator</em> - the returned value of the previous iteration</p>
</li>
<li><p><em>currentValue</em> - the current item in the array</p>
</li>
<li><p><em>index</em> - the index of the current item</p>
</li>
<li><p><em>array</em> - the original array on which reduce was called</p>
</li>
<li><p>The <code>initialValue</code> argument is optional. If provided, it will be used as the initial accumulator value in the first call to the callback function.</p>
</li>
</ul>
<h3><strong>Examples</strong></h3>
<p>The following example adds every number together in an array of numbers.</p>
<pre><code class="language-javascript">const numbers = [1, 2, 3, 4];
const sum = numbers.reduce(function (result, item) {
  return result + item;
}, 0);
console.log(sum); // 10
</code></pre>
<p>In the next example, <code>reduce()</code> is used to transform an array of strings into a single object that shows how many times each string appears in the array. Notice this call to reduce passes an empty object <code>{}</code> as the <code>initialValue</code> parameter. This will be used as the initial value of the accumulator (the first argument) passed to the callback function.</p>
<pre><code class="language-javascript">var pets = ['dog', 'chicken', 'cat', 'dog', 'chicken', 'chicken', 'rabbit'];

var petCounts = pets.reduce(function(obj, pet){
    if (!obj[pet]) {
        obj[pet] = 1;
    } else {
        obj[pet]++;
    }
    return obj;
}, {});

console.log(petCounts); 

/*
Output:
 { 
    dog: 2, 
    chicken: 3, 
    cat: 1, 
    rabbit: 1 
 }
 */
</code></pre>
<h2>✤ forEach()</h2>
<p>The <strong>JavaScript Array forEach() method</strong> is a built-in function that executes a provided function once for each array element. It does not return a new array and does not modify the original array. It's commonly used for iteration and performing actions on each array element.</p>
<h2><strong>Return value</strong></h2>
<p>It does not return a new array. It returns undefined. This method may or may not change the original array provided as it depends upon the functionality of the argument function.</p>
<img src="https://cdn.hashnode.com/uploads/covers/656ed88ac1f28c5dd219df1a/e8892802-2637-40a3-a3e0-c44b5ef1ad0e.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h3><strong>Want More…?</strong></h3>
<p>I write articles on <a href="http://blog.prakashtsx.com"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[CSS Selectors Explained]]></title><description><![CDATA[Why Do We Need CSS Selectors?
Imagine you have a webpage with:

headings

paragraphs

buttons

cards

links


CSS needs a way to answer one simple question:

Which element should I style?

That’s exactly what CSS selectors do.
Selectors are used to c...]]></description><link>https://blog.prakashtsx.me/css-selectors</link><guid isPermaLink="true">https://blog.prakashtsx.me/css-selectors</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[CSS]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Fri, 30 Jan 2026 14:40:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769783971731/f7b212d6-b873-47e0-88ec-19a419edcc32.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-why-do-we-need-css-selectors">Why Do We Need CSS Selectors?</h2>
<p>Imagine you have a webpage with:</p>
<ul>
<li><p>headings</p>
</li>
<li><p>paragraphs</p>
</li>
<li><p>buttons</p>
</li>
<li><p>cards</p>
</li>
<li><p>links</p>
</li>
</ul>
<p>CSS needs a way to answer one simple question:</p>
<blockquote>
<p><strong>Which element should I style?</strong></p>
</blockquote>
<p>That’s exactly what <strong>CSS selectors</strong> do.</p>
<p><strong>Selectors are used to choose HTML elements</strong> so CSS can apply styles to them.</p>
<p>Without selectors, CSS wouldn’t know <strong>where</strong> to apply styles.</p>
<h2 id="heading-css-selectors-ways-to-choose-elements">CSS Selectors = Ways to Choose Elements</h2>
<p>Think of CSS selectors like <strong>addressing people</strong>.</p>
<ul>
<li><p>“All students” → element selector</p>
</li>
<li><p>“Students wearing red shirts” → class selector</p>
</li>
<li><p>“That one student with roll no. 12” → ID selector</p>
</li>
</ul>
<p>CSS works the same way.</p>
<h2 id="heading-element-selector">Element Selector</h2>
<p>The <strong>element selector</strong> selects HTML elements by their tag name.</p>
<h3 id="heading-example">Example</h3>
<p><strong>HTML</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is a paragraph<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is another paragraph<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p><strong>CSS</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: blue;
}
</code></pre>
<h3 id="heading-result">Result</h3>
<p>All <code>&lt;p&gt;</code> elements become blue.</p>
<p>Use element selectors when:</p>
<ul>
<li>You want to style <strong>all elements of the same type</strong></li>
</ul>
<h2 id="heading-class-selector">Class Selector</h2>
<p>The <strong>class selector</strong> targets elements with a specific class.</p>
<h3 id="heading-syntax">Syntax</h3>
<pre><code class="lang-css"><span class="hljs-selector-class">.class-name</span>
</code></pre>
<h3 id="heading-example-1">Example</h3>
<p><strong>HTML</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"highlight"</span>&gt;</span>Important text<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Normal text<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p><strong>CSS</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-class">.highlight</span> {
  <span class="hljs-attribute">color</span>: red;
}
</code></pre>
<h3 id="heading-result-1">Result</h3>
<p>Only the paragraph with class <code>highlight</code> is red.</p>
<p>Use class selectors when:</p>
<ul>
<li>You want to style <strong>multiple specific elements</strong></li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769783233772/542f8de2-ef4e-4612-87d1-2765662f2db3.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-id-selector">ID Selector</h2>
<p>The <strong>ID selector</strong> targets a single unique element.</p>
<h3 id="heading-syntax-1">Syntax</h3>
<pre><code class="lang-css"><span class="hljs-selector-id">#id-name</span>
</code></pre>
<h3 id="heading-example-2">Example</h3>
<p><strong>HTML</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"main-title"</span>&gt;</span>Welcome<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
</code></pre>
<p><strong>CSS</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-id">#main-title</span> {
  <span class="hljs-attribute">color</span>: green;
}
</code></pre>
<h3 id="heading-result-2">Result</h3>
<p>Only that one heading is styled.</p>
<p>Rules:</p>
<ul>
<li><p>IDs must be <strong>unique</strong></p>
</li>
<li><p>Use IDs sparingly</p>
</li>
</ul>
<h2 id="heading-group-selectors">Group Selectors</h2>
<p>Group selectors let you apply the <strong>same style to multiple selectors</strong>.</p>
<h3 id="heading-example-3">Example</h3>
<p><strong>CSS</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-tag">h1</span>, <span class="hljs-selector-tag">h2</span>, <span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">font-family</span>: Arial;
}
</code></pre>
<h3 id="heading-result-3">Result</h3>
<p><code>h1</code>, <code>h2</code>, and <code>p</code> all use Arial.</p>
<p>Use group selectors to:</p>
<ul>
<li><p>Avoid repeating CSS</p>
</li>
<li><p>Keep styles clean</p>
</li>
</ul>
<h2 id="heading-descendant-selectors">Descendant Selectors</h2>
<p>Descendant selectors target elements <strong>inside other elements</strong>.</p>
<h3 id="heading-syntax-2">Syntax</h3>
<pre><code class="lang-css"><span class="hljs-selector-tag">parent</span> <span class="hljs-selector-tag">child</span>
</code></pre>
<h3 id="heading-example-4">Example</h3>
<p><strong>HTML</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This text is inside card<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This text is outside card<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p><strong>CSS</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-class">.card</span> <span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: blue;
}
</code></pre>
<h3 id="heading-result-4">Result</h3>
<p>Only the paragraph inside <code>.card</code> turns blue.</p>
<p>This is very useful for layouts and components.</p>
<h2 id="heading-basic-selector-priority-high-level-only">Basic Selector Priority (High-Level Only)</h2>
<p>Sometimes multiple selectors target the same element.</p>
<p>CSS follows a simple priority rule:</p>
<pre><code class="lang-text">ID selector &gt; Class selector &gt; Element selector
</code></pre>
<h3 id="heading-example-5">Example</h3>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: black;
}

<span class="hljs-selector-class">.text</span> {
  <span class="hljs-attribute">color</span>: blue;
}

<span class="hljs-selector-id">#special</span> {
  <span class="hljs-attribute">color</span>: red;
}
</code></pre>
<p>If an element has all three:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"special"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"text"</span>&gt;</span>Hello<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p><strong>Red wins</strong> because ID has higher priority.</p>
<p>Don’t worry about memorizing this now.<br />Just remember: <strong>ID is stronger than class, class is stronger than element</strong>.</p>
<p>CSS works like this:</p>
<ol>
<li><p>Read selector</p>
</li>
<li><p>Find matching elements</p>
</li>
<li><p>Apply styles</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769783430228/c7d1a361-483e-4a6d-b908-ff495c5ce600.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-why-css-selectors-are-so-important">Why CSS Selectors Are So Important</h2>
<p>Selectors are the <strong>foundation of CSS</strong>.</p>
<p>If you understand selectors:</p>
<ul>
<li><p>Styling becomes easy</p>
</li>
<li><p>Layouts make sense</p>
</li>
<li><p>Debugging becomes faster</p>
</li>
</ul>
<p>Everything in CSS starts with:</p>
<blockquote>
<p><strong>Which element am I targeting?</strong></p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769783524124/418365a3-d86b-4c58-a3d2-fae1a030dee5.png" alt class="image--center mx-auto" /></p>
<hr />
<h3 id="heading-want-more"><strong>Want More…?</strong></h3>
<p>I write articles on <a target="_blank" href="https://blog.prakashtsx.me/"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a target="_blank" href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Emmet for HTML]]></title><description><![CDATA[The Problem: Writing HTML Is Slow
Type this by hand:
<div class="container">
  <header class="header">
    <h1>Welcome</h1>
  </header>
  <main class="content">
    <p>This is a paragraph.</p>
  </main>
</div>

That's a lot of typing. Opening tags, c...]]></description><link>https://blog.prakashtsx.me/emmet-for-html</link><guid isPermaLink="true">https://blog.prakashtsx.me/emmet-for-html</guid><category><![CDATA[Hashnode]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[Emmet]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Fri, 30 Jan 2026 14:05:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769781857096/e8542104-029c-4390-8374-9dad72907efb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-the-problem-writing-html-is-slow"><strong>The Problem: Writing HTML Is Slow</strong></h2>
<p>Type this by hand:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">header</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"header"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">main</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"content"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is a paragraph.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>That's a lot of typing. Opening tags, closing tags, attributes, indentation. Every single character.</p>
<p>Now imagine building a full webpage with dozens or hundreds of elements. It gets tedious fast.</p>
<p><strong>There has to be a better way.</strong></p>
<h2 id="heading-what-is-emmet"><strong>What Is Emmet?</strong></h2>
<p><strong>Emmet</strong> is a shortcut language that lets you write HTML incredibly fast.</p>
<p>Instead of typing full HTML tags, you type a short abbreviation and press Tab. Emmet expands it into complete HTML.</p>
<p><strong>Example:</strong></p>
<p>Type this:</p>
<pre><code class="lang-bash">div.container
</code></pre>
<p>Press <strong>Tab</strong></p>
<p>Get this:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Emmet isn't a separate tool you install. It's built into most modern code editors like VS Code, Sublime Text, and Atom. It just works.</p>
<h2 id="heading-why-beginners-should-use-emmet"><strong>Why Beginners Should Use Emmet</strong></h2>
<p><strong>1. Write HTML 10x faster</strong> Less typing means you focus on structure, not syntax.</p>
<p><strong>2. Fewer mistakes</strong> Emmet generates valid HTML. No forgotten closing tags or typos.</p>
<p><strong>3. Learn HTML structure better</strong> Emmet forces you to think in terms of hierarchy and nesting.</p>
<p><strong>4. Industry standard</strong> Professional developers use Emmet daily. Learning it early gives you good habits.</p>
<p><strong>5. It's optional</strong> You can always type HTML manually. Emmet is there when you want speed.</p>
<h2 id="heading-how-emmet-works"><strong>How Emmet Works</strong></h2>
<p>Emmet watches what you type in your editor. When it recognizes an abbreviation, it offers to expand it.</p>
<p><strong>Step-by-step:</strong></p>
<ol>
<li><p>Type an Emmet abbreviation: <code>p</code></p>
</li>
<li><p>Press <strong>Tab</strong> (or Enter in some editors)</p>
</li>
<li><p>Emmet expands it: <code>&lt;p&gt;&lt;/p&gt;</code></p>
</li>
<li><p>Your cursor is inside the tag, ready to add content</p>
</li>
</ol>
<p><strong>Most editors with Emmet support:</strong></p>
<ul>
<li><p>VS Code (built-in)</p>
</li>
<li><p>Sublime Text (built-in)</p>
</li>
<li><p>Atom (built-in)</p>
</li>
<li><p>WebStorm (built-in)</p>
</li>
</ul>
<p>If you're using VS Code, Emmet works out of the box. Just type and press Tab.</p>
<h2 id="heading-basic-emmet-syntax"><strong>Basic Emmet Syntax</strong></h2>
<h3 id="heading-creating-elements"><strong>Creating Elements</strong></h3>
<p>Type the tag name and press Tab.</p>
<pre><code class="lang-xml">h1    →    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
p     →    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
div   →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
span  →    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
</code></pre>
<h3 id="heading-adding-classes"><strong>Adding Classes</strong></h3>
<p>Use a dot (<code>.</code>) for classes.</p>
<pre><code class="lang-xml">div.container    →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
p.intro          →    <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"intro"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p><strong>Multiple classes:</strong></p>
<pre><code class="lang-xml">div.card.shadow    →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card shadow"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h3 id="heading-adding-ids"><strong>Adding IDs</strong></h3>
<p>Use a hash (<code>#</code>) for IDs.</p>
<pre><code class="lang-php-template"><span class="xml">div#main      →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"main"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
header#top    →    <span class="hljs-tag">&lt;<span class="hljs-name">header</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"top"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span></span>
</code></pre>
<h3 id="heading-combining-classes-and-ids"><strong>Combining Classes and IDs</strong></h3>
<pre><code class="lang-xml">div#main.container    →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"main"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p><strong>Order doesn't matter:</strong></p>
<pre><code class="lang-xml">div.container#main    →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"main"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h3 id="heading-implicit-tag-names"><strong>Implicit Tag Names</strong></h3>
<p>If you don't specify a tag, Emmet assumes <code>div</code>.</p>
<pre><code class="lang-xml">.container       →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
#header          →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"header"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
.card.shadow     →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card shadow"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h2 id="heading-adding-attributes"><strong>Adding Attributes</strong></h2>
<p>Use square brackets <code>[]</code> for custom attributes.</p>
<pre><code class="lang-xml">a[href="#"]                →    <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"#"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
img[src="photo.jpg"]       →    <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"photo.jpg"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">""</span>&gt;</span>
input[type="text"]         →    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span>&gt;</span>
</code></pre>
<p><strong>Multiple attributes:</strong></p>
<pre><code class="lang-xml">img[src="car.jpg" alt="Red car"]    →    <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"car.jpg"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"Red car"</span>&gt;</span>
</code></pre>
<h2 id="heading-creating-nested-elements"><strong>Creating Nested Elements</strong></h2>
<p>Use the <code>&gt;</code> symbol to create child elements.</p>
<pre><code class="lang-xml">div&gt;p    →    <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p><strong>More complex nesting:</strong></p>
<pre><code class="lang-xml">header&gt;h1
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
</code></pre>
<p><strong>Deeper nesting:</strong></p>
<pre><code class="lang-bash">div&gt;header&gt;h1
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h2 id="heading-sibling-elements"><strong>Sibling Elements</strong></h2>
<p>Use the <code>+</code> symbol to create elements at the same level.</p>
<pre><code class="lang-bash">header+main
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
</code></pre>
<p><strong>Multiple siblings:</strong></p>
<pre><code class="lang-bash">header+main+footer
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">footer</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">footer</span>&gt;</span>
</code></pre>
<h2 id="heading-combining-nesting-and-siblings"><strong>Combining Nesting and Siblings</strong></h2>
<pre><code class="lang-bash">div&gt;header+main+footer
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">footer</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">footer</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p><strong>More complex:</strong></p>
<pre><code class="lang-bash">div.container&gt;header&gt;h1^main&gt;p^footer
</code></pre>
<p>The <code>^</code> climbs back up one level.</p>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">footer</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">footer</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h2 id="heading-repeating-elements-with-multiplication"><strong>Repeating Elements with Multiplication</strong></h2>
<p>Use <code>*</code> to create multiple copies.</p>
<pre><code class="lang-bash">li*3
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
</code></pre>
<p><strong>Real-world example:</strong></p>
<pre><code class="lang-bash">ul&gt;li*5
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<p><strong>With classes:</strong></p>
<pre><code class="lang-bash">div.card*3
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h2 id="heading-auto-numbering-with"><strong>Auto-Numbering with $</strong></h2>
<p>Use <code>$</code> to add auto-incrementing numbers.</p>
<pre><code class="lang-bash">div.item$*3
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"item1"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"item2"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"item3"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p><strong>In IDs:</strong></p>
<pre><code class="lang-bash">section<span class="hljs-comment">#section$*3</span>
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">section</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"section1"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">section</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"section2"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">section</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"section3"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>
</code></pre>
<h2 id="heading-adding-text-content"><strong>Adding Text Content</strong></h2>
<p>Use curly braces <code>{}</code> for text.</p>
<pre><code class="lang-bash">h1{Welcome}
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
</code></pre>
<p><strong>With nested elements:</strong></p>
<pre><code class="lang-bash">div&gt;h1{Title}+p{Description}
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Title<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Description<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p><strong>Numbered text:</strong></p>
<pre><code class="lang-bash">li{Item $}*3
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Item 1<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Item 2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Item 3<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
</code></pre>
<h2 id="heading-generating-html-boilerplate"><strong>Generating HTML Boilerplate</strong></h2>
<p>The most powerful Emmet trick: generate a full HTML template instantly.</p>
<p>Type:</p>
<pre><code class="lang-bash">!
</code></pre>
<p>Press <strong>Tab</strong></p>
<p>Get this:</p>
<pre><code class="lang-xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Document<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p><strong>This saves you from typing 10+ lines every time you create a new HTML file.</strong></p>
<p>Alternative syntax (does the same thing):</p>
<pre><code class="lang-bash">html:5
</code></pre>
<h2 id="heading-real-world-examples"><strong>Real-World Examples</strong></h2>
<h3 id="heading-navigation-menu"><strong>Navigation Menu</strong></h3>
<pre><code class="lang-bash">nav&gt;ul&gt;li*4&gt;a
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">""</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">""</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">""</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">""</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>
</code></pre>
<h3 id="heading-card-grid"><strong>Card Grid</strong></h3>
<pre><code class="lang-bash">div.grid&gt;div.card*3&gt;h2+p
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"grid"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h3 id="heading-form"><strong>Form</strong></h3>
<pre><code class="lang-bash">form&gt;input[<span class="hljs-built_in">type</span>=<span class="hljs-string">"text"</span>]+input[<span class="hljs-built_in">type</span>=<span class="hljs-string">"email"</span>]+button{Submit}
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">""</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<h3 id="heading-table"><strong>Table</strong></h3>
<pre><code class="lang-bash">table&gt;tr*3&gt;td*4
</code></pre>
<p>Expands to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">table</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">table</span>&gt;</span>
</code></pre>
<h2 id="heading-emmet-cheat-sheet"><strong>Emmet Cheat Sheet</strong></h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Abbreviation</td><td>Result</td></tr>
</thead>
<tbody>
<tr>
<td><code>div</code></td><td><code>&lt;div&gt;&lt;/div&gt;</code></td></tr>
<tr>
<td><code>.class</code></td><td><code>&lt;div class="class"&gt;&lt;/div&gt;</code></td></tr>
<tr>
<td><code>#id</code></td><td><code>&lt;div id="id"&gt;&lt;/div&gt;</code></td></tr>
<tr>
<td><code>div&gt;p</code></td><td><code>&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</code></td></tr>
<tr>
<td><code>div+p</code></td><td><code>&lt;div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</code></td></tr>
<tr>
<td><code>div*3</code></td><td>3 divs</td></tr>
<tr>
<td><code>div.item$*3</code></td><td>divs with item1, item2, item3</td></tr>
<tr>
<td><code>a[href]</code></td><td><code>&lt;a href=""&gt;&lt;/a&gt;</code></td></tr>
<tr>
<td><code>p{text}</code></td><td><code>&lt;p&gt;text&lt;/p&gt;</code></td></tr>
<tr>
<td><code>!</code></td><td>Full HTML template</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-for-cheat-sheet-you-can-visit-here-official-documentationhttpsdocsemmetiocheat-sheet"><mark>For Cheat Sheet You can visit here</mark> : <a target="_blank" href="https://docs.emmet.io/cheat-sheet/">Official Documentation</a></h2>
<h3 id="heading-want-more"><strong>Want More…?</strong></h3>
<p>I write articles on <a target="_blank" href="https://blog.prakashtsx.me/"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a target="_blank" href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Understanding HTML Tags and Elements]]></title><description><![CDATA[What Is HTML and Why Do We Use It?
HTML (HyperText Markup Language) is used to create the structure of a webpage.
When you open a website, the browser first reads HTML code to know:

What text to show

What is a heading

What is a paragraph

Where im...]]></description><link>https://blog.prakashtsx.me/html-tags-and-elements</link><guid isPermaLink="true">https://blog.prakashtsx.me/html-tags-and-elements</guid><category><![CDATA[HTML5]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Fri, 30 Jan 2026 13:26:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769779445002/66a0fd6f-ac45-4784-914f-ceed4f88b170.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-html-and-why-do-we-use-it">What Is HTML and Why Do We Use It?</h2>
<p><strong>HTML (HyperText Markup Language)</strong> is used to <strong>create the structure of a webpage</strong>.</p>
<p>When you open a website, the browser first reads <strong>HTML code</strong> to know:</p>
<ul>
<li><p>What text to show</p>
</li>
<li><p>What is a heading</p>
</li>
<li><p>What is a paragraph</p>
</li>
<li><p>Where images and links are placed</p>
</li>
</ul>
<p>Think of HTML as the <strong>skeleton</strong> of a webpage.</p>
<h2 id="heading-html-skeleton-of-a-webpage">HTML = Skeleton of a Webpage</h2>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>My Website<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Welcome to my page<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>Without HTML, the browser has <strong>nothing to display</strong>.</p>
<h2 id="heading-what-is-an-html-tag">What Is an HTML Tag?</h2>
<p>An <strong>HTML tag</strong> is written inside angle brackets <code>&lt; &gt;</code>.</p>
<p>Example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>This tag tells the browser:</p>
<blockquote>
<p>“This is a paragraph.”</p>
</blockquote>
<p>Some common tags:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>
</code></pre>
<h2 id="heading-opening-tag-closing-tag-and-content">Opening Tag, Closing Tag, and Content</h2>
<p>Most HTML tags have:</p>
<ul>
<li><p>an <strong>opening tag</strong></p>
</li>
<li><p><strong>content</strong></p>
</li>
<li><p>a <strong>closing tag</strong></p>
</li>
</ul>
<p>Example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Hello World<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>Breakdown:</p>
<ul>
<li><p><code>&lt;p&gt;</code> → opening tag</p>
</li>
<li><p><code>Hello World</code> → content</p>
</li>
<li><p><code>&lt;/p&gt;</code> → closing tag</p>
</li>
</ul>
<p>Think of it like a <strong>box</strong>:</p>
<pre><code class="lang-text">&lt;p&gt;        ← open
Hello World
&lt;/p&gt;       ← close
</code></pre>
<h2 id="heading-what-is-an-html-element">What Is an HTML Element?</h2>
<p><em>This is very important</em></p>
<p><strong>HTML element = opening tag + content + closing tag</strong></p>
<p>Example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>This is a heading<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
</code></pre>
<ul>
<li><p><code>&lt;h1&gt;</code> → tag</p>
</li>
<li><p><code>&lt;/h1&gt;</code> → tag</p>
</li>
<li><p>Whole line → <strong>HTML element</strong></p>
</li>
</ul>
<p><strong>Tag ≠ Element</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769779076781/0cbf3e4b-24d9-44ed-aabf-b703d6dc6ddb.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-self-closing-void-elements">Self-Closing (Void) Elements</h2>
<p>Some elements <strong>do not have content</strong>.</p>
<p>Example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"photo.jpg"</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> /&gt;</span>
</code></pre>
<p>These are called <strong>self-closing (void) elements</strong>.</p>
<p><strong>They:</strong></p>
<ul>
<li><p>Don’t wrap text</p>
</li>
<li><p>Don’t need closing tags</p>
</li>
</ul>
<h2 id="heading-block-level-elements">Block-Level Elements</h2>
<p>Block elements:</p>
<ul>
<li><p>Start on a new line</p>
</li>
<li><p>Take full width</p>
</li>
</ul>
<p>Example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Heading<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is a paragraph<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>This is a div<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>They appear like this:</p>
<pre><code class="lang-text">[ Heading          ]
[ Paragraph        ]
[ Div              ]
</code></pre>
<h2 id="heading-inline-elements">Inline Elements</h2>
<p>Inline elements:</p>
<ul>
<li><p>Stay in the same line</p>
</li>
<li><p>Take only required space</p>
</li>
</ul>
<p>Example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
  This is <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>inline text<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> inside a paragraph.
<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>Inline elements behave like <strong>words in a sentence</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769778863216/fd4ca0e2-dc05-42f7-8130-8819c3761110.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-commonly-used-html-tags-beginner-friendly">Commonly Used HTML Tags (Beginner-Friendly)</h2>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Main heading<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Sub heading<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is a paragraph.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Paragraph inside div<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>Small inline text<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://blog.prakashtsx.me"</span>&gt;</span>Visit my blog<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"image.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"My image"</span> /&gt;</span>
</code></pre>
<p><em>These tags are more than enough to start.</em></p>
<h2 id="heading-inspect-html-in-the-browser-must-try">Inspect HTML in the Browser (Must Try)</h2>
<ol>
<li><p>Open any website</p>
</li>
<li><p>Right-click → <strong>Inspect</strong></p>
</li>
<li><p>Look at the <strong>Elements</strong> tab</p>
</li>
</ol>
<p>You’ll see real HTML like:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Title<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Text<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<hr />
<h3 id="heading-want-more"><strong>Want More…?</strong></h3>
<p>I write articles on <a target="_blank" href="https://blog.prakashtsx.me/"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a target="_blank" href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How a Browser Works : A Beginner-Friendly Guide to Browser Internals]]></title><description><![CDATA[What Really Happens When You Type blog.prakashtsx.me in Your Browser?

From URL → code → pixels (explained visually for beginners)

A Simple Question to Start With
You open your browser, type:
blog.prakashtsx.me
…and press Enter.
Within milliseconds,...]]></description><link>https://blog.prakashtsx.me/browser-internals</link><guid isPermaLink="true">https://blog.prakashtsx.me/browser-internals</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[Browsers]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Fri, 30 Jan 2026 12:51:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769777412184/cd8252fa-003a-4933-80a7-afb15a332f15.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-what-really-happens-when-you-type-blogprakashtsxmehttpblogprakashtsxme-in-your-browser">What Really Happens When You Type <a target="_blank" href="http://blog.prakashtsx.me"><code>blog.prakashtsx.me</code></a> in Your Browser?</h3>
<blockquote>
<p>From URL → code → pixels (explained visually for beginners)</p>
</blockquote>
<h2 id="heading-a-simple-question-to-start-with">A Simple Question to Start With</h2>
<p>You open your browser, type:</p>
<p><a target="_blank" href="http://blog.prakashtsx.me"><code>blog.prakashtsx.me</code></a></p>
<p>…and press <strong>Enter</strong>.</p>
<p>Within milliseconds, blog appears.</p>
<p>But what <em>actually</em> happened inside the browser during that tiny moment?</p>
<p>Let’s Understand :</p>
<h2 id="heading-what-a-browser-actually-is-beyond-it-opens-websites">What a Browser Actually Is (Beyond “It Opens Websites”)</h2>
<p>A browser is <strong>not just a website opener</strong>.</p>
<p>When you visit <a target="_blank" href="http://blog.prakashtsx.me"><code>blog.prakashtsx.me</code></a>, your browser becomes:</p>
<ul>
<li><p>A <strong>network client</strong> (talks to servers)</p>
</li>
<li><p>A <strong>file downloader</strong> (HTML, CSS, JS)</p>
</li>
<li><p>A <strong>parser</strong> (understands code)</p>
</li>
<li><p>A <strong>layout planner</strong></p>
</li>
<li><p>A <strong>painter</strong> (draws pixels)</p>
</li>
</ul>
<p><strong><em>In simple words:</em></strong></p>
<blockquote>
<p><strong>A browser converts text files into a visual experience.</strong></p>
</blockquote>
<h2 id="heading-main-parts-of-a-browser-high-level-overview">Main Parts of a Browser (High-Level Overview)</h2>
<p>Think of the browser as a <strong>team of components working together</strong>.</p>
<h3 id="heading-main-components">Main components:</h3>
<ul>
<li><p>User Interface</p>
</li>
<li><p>Browser Engine</p>
</li>
<li><p>Rendering Engine</p>
</li>
<li><p>Networking</p>
</li>
<li><p>JavaScript Engine</p>
</li>
<li><p>Data Storage</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769776290776/07f2d41f-1355-46bf-a09a-b0f8f9cd02e4.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-user-interface-what-you-see">User Interface (What You See)</h2>
<p>This is the visible part of the browser:</p>
<ul>
<li><p>Address bar (where you type <a target="_blank" href="http://blog.prakashtsx.me"><code>blog.prakashtsx.me</code></a>)</p>
</li>
<li><p>Tabs</p>
</li>
<li><p>Back / Forward buttons</p>
</li>
<li><p>Refresh button</p>
</li>
</ul>
<p><strong><em>Important:</em></strong><br />The UI <strong>does not render the website</strong>.<br />It only sends instructions to the browser engine.</p>
<h2 id="heading-browser-engine-vs-rendering-engine-simple-difference">Browser Engine vs Rendering Engine (Simple Difference)</h2>
<p>This confuses many beginners, so let’s simplify.</p>
<h3 id="heading-browser-engine">Browser Engine</h3>
<ul>
<li><p>Acts like a <strong>manager</strong></p>
</li>
<li><p>Connects UI with the rendering engine</p>
</li>
<li><p>Controls page loading</p>
</li>
</ul>
<h3 id="heading-rendering-engine">Rendering Engine</h3>
<ul>
<li><p>Converts <strong>HTML + CSS into pixels</strong></p>
</li>
<li><p>Builds DOM, CSSOM, Render Tree</p>
</li>
</ul>
<p>Examples (name-level only):</p>
<ul>
<li><p>Chrome → Blink</p>
</li>
<li><p>Firefox → Gecko</p>
</li>
</ul>
<p><em>One manages. One draws.</em></p>
<h2 id="heading-networking-how-blogprakashtsxmehttpblogprakashtsxme-is-fetched">Networking: How <a target="_blank" href="http://blog.prakashtsx.me"><code>blog.prakashtsx.me</code></a> Is Fetched</h2>
<p>After pressing Enter:</p>
<ol>
<li><p>Browser reads the URL</p>
</li>
<li><p>DNS converts domain → IP address</p>
</li>
<li><p>Browser sends an HTTP/HTTPS request</p>
</li>
<li><p>Server responds with:</p>
<ul>
<li><p>HTML</p>
</li>
<li><p>CSS</p>
</li>
<li><p>JavaScript</p>
</li>
<li><p>Images, fonts</p>
</li>
</ul>
</li>
</ol>
<p>At this stage, the browser has <strong>raw files</strong>, not a page.</p>
<h2 id="heading-html-parsing-dom-creation">HTML Parsing → DOM Creation</h2>
<p>Let’s say blog sends HTML like:</p>
<pre><code class="lang-plaintext">&lt;html&gt;
  &lt;body&gt;
    &lt;div&gt;Hello from blog.prakashtsx.me&lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>The browser:</p>
<ul>
<li><p>Reads HTML line by line</p>
</li>
<li><p>Breaks it into tokens</p>
</li>
<li><p>Builds a tree structure</p>
</li>
</ul>
<p>This tree is called the <strong>DOM (Document Object Model)</strong>.</p>
<h3 id="heading-dom-analogy">DOM Analogy</h3>
<p>Think of DOM as a <strong>family tree</strong>:</p>
<ul>
<li><p><code>html</code> → parent</p>
</li>
<li><p><code>body</code> → child</p>
</li>
<li><p><code>div</code> → grandchild</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769776547307/f141c751-28d4-40b0-bbcb-4b1064a047ad.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-css-parsing-cssom-creation">CSS Parsing → CSSOM Creation</h2>
<p>  CSS is processed separately.</p>
<p>  Example:</p>
<pre><code class="lang-plaintext">  body { font-size: 16px; }
  div { color: blue; }
</code></pre>
<p>  The browser:</p>
<ul>
<li><p>Tokenizes CSS</p>
</li>
<li><p>Applies rules</p>
</li>
<li><p>Handles inheritance</p>
</li>
</ul>
</li>
</ul>
<p>    This creates the <strong>CSSOM (CSS Object Model)</strong>.</p>
<p>    <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769776592957/1cf7ec09-6df8-4098-bb17-48562d66e199.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-how-dom-and-cssom-come-together">How DOM and CSSOM Come Together</h2>
<p>    Now the browser combines:</p>
<ul>
<li><p>DOM (structure)</p>
</li>
<li><p>CSSOM (styles)</p>
</li>
</ul>
<p>    To form the <strong>Render Tree</strong>.</p>
<h3 id="heading-render-tree">Render Tree:</h3>
<ul>
<li><p>Contains only <strong>visible elements</strong></p>
</li>
<li><p>Includes layout + style info</p>
</li>
</ul>
<p>    <em>Elements like</em> <code>display: none</code> <em>are excluded.</em></p>
<p>    <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769776640100/5f2befcd-1f94-459f-aee3-fd45ca60c9cc.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-layout-reflow-deciding-positions">Layout (Reflow): Deciding Positions</h2>
<p>    Now the browser calculates:</p>
<ul>
<li><p>Width</p>
</li>
<li><p>Height</p>
</li>
<li><p>Position (x, y)</p>
</li>
</ul>
<p>    <em>This step is called</em> <strong><em>Layout</em></strong> <em>or</em> <strong><em>Reflow*</em></strong>.*</p>
<p>    Reflow happens again if:</p>
<ul>
<li><p>Window resizes</p>
</li>
<li><p>Content changes</p>
</li>
<li><p>Font size changes</p>
</li>
</ul>
<h2 id="heading-painting-and-display">Painting and Display</h2>
<h3 id="heading-painting">Painting</h3>
<p>    The browser paints:</p>
<ul>
<li><p>Text</p>
</li>
<li><p>Colors</p>
</li>
<li><p>Borders</p>
</li>
<li><p>Images</p>
</li>
</ul>
<h3 id="heading-compositing-amp-display">Compositing &amp; Display</h3>
<ul>
<li><p>Layers are combined</p>
</li>
<li><p>Pixels are pushed to the screen</p>
</li>
</ul>
<p>    🎉 You now see <a target="_blank" href="http://blog.prakashtsx.me"><strong>blog.prakashtsx.me</strong></a></p>
<p>    <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769776885130/cc14b335-cbaa-4cfb-b11d-2f4975e2300d.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-does-parsing-mean">What Does “Parsing” Mean?</h2>
<p>    Parsing means:</p>
<blockquote>
<p><strong>Breaking something into meaningful structure</strong></p>
</blockquote>
<p>    <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769776983497/f9cff355-84d0-4d54-b008-ee94d2cf7aa0.png" alt class="image--center mx-auto" /></p>
<p>    Example:</p>
<pre><code class="lang-plaintext">    2 + 3 * 4
</code></pre>
<p>    Parser understands:</p>
<ul>
<li><p><code>*</code> has higher priority</p>
</li>
<li><p>Builds a tree</p>
</li>
<li><p>Evaluates correctly</p>
</li>
</ul>
<hr />
<h3 id="heading-want-more"><strong>Want More…?</strong></h3>
<p>I write articles on <a target="_blank" href="https://blog.prakashtsx.me/"><strong>blog.prakashtsx.com</strong></a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a target="_blank" href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[TCP Working: 3-Way Handshake & Reliable Communication]]></title><description><![CDATA[Introduction: What if the Internet Had No Rules?
Imagine you want to send a message to your friend.
You shout the message.Your friend may or may not hear it.Even if they hear, they might hear it in the wrong order.Some words may be lost.Some words ma...]]></description><link>https://blog.prakashtsx.me/3-way-handshake</link><guid isPermaLink="true">https://blog.prakashtsx.me/3-way-handshake</guid><category><![CDATA[Hashnode]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Thu, 29 Jan 2026 19:34:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769715156223/e8428229-371d-4926-91d3-19f99250e2bc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction-what-if-the-internet-had-no-rules">Introduction: What if the Internet Had No Rules?</h2>
<p>Imagine you want to send a message to your friend.</p>
<p>You shout the message.<br />Your friend may or may not hear it.<br />Even if they hear, they might hear it in the wrong order.<br />Some words may be lost.<br />Some words may be repeated.</p>
<p>That’s exactly what would happen on the internet <strong>if there were no rules</strong>.</p>
<p>The internet is just millions of computers sending data to each other.<br />To make sure this data reaches the correct destination, <strong>in the correct order</strong>, and <strong>without loss</strong>, we need proper rules.</p>
<p>These rules are called <strong>protocols</strong>.</p>
<p>One of the most important protocols is <strong>TCP</strong>.</p>
<h2 id="heading-what-is-tcp-and-why-is-it-needed">What is TCP and Why Is It Needed?</h2>
<p><strong>TCP</strong> stands for <strong>Transmission Control Protocol</strong>.</p>
<p>TCP is a communication protocol that makes sure:</p>
<ul>
<li><p>Data reaches the correct destination</p>
</li>
<li><p>Data is not lost</p>
</li>
<li><p>Data arrives in the correct order</p>
</li>
<li><p>Data is not duplicated</p>
</li>
<li><p>Sender and receiver both agree before talking</p>
</li>
</ul>
<p>In simple words:</p>
<blockquote>
<p><strong>TCP makes the internet reliable.</strong></p>
</blockquote>
<p>Whenever you:</p>
<ul>
<li><p>Open a website</p>
</li>
<li><p>Log in to an app</p>
</li>
<li><p>Submit a form</p>
</li>
<li><p>Send an email</p>
</li>
</ul>
<p>TCP is working silently in the background.</p>
<h2 id="heading-problems-tcp-is-designed-to-solve">Problems TCP Is Designed to Solve</h2>
<p>Before understanding how TCP works, let’s understand <strong>what problems exist without TCP</strong>.</p>
<h3 id="heading-1-data-loss">1. Data Loss</h3>
<p>Packets can get lost due to:</p>
<ul>
<li><p>Network congestion</p>
</li>
<li><p>Weak connections</p>
</li>
<li><p>Hardware failures</p>
</li>
</ul>
<h3 id="heading-2-wrong-order-of-data">2. Wrong Order of Data</h3>
<p>Data is broken into small packets.<br />Packets can arrive <strong>out of order</strong>.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">Sent: Hello World
Received: World Hello
</code></pre>
<h3 id="heading-3-duplicate-data">3. Duplicate Data</h3>
<p>Sometimes the same packet can arrive multiple times.</p>
<h3 id="heading-4-no-confirmation">4. No Confirmation</h3>
<p>Sender doesn’t know:</p>
<ul>
<li><p>Did the receiver get the data?</p>
</li>
<li><p>Should I resend?</p>
</li>
</ul>
<p>TCP solves <strong>all these problems</strong>.</p>
<h2 id="heading-introducing-tcp-as-a-reliable-protocol">Introducing TCP as a Reliable Protocol</h2>
<p>TCP works like a <strong>formal conversation</strong>.</p>
<p>Before sending data:</p>
<ul>
<li><p>TCP checks if the other side is ready</p>
</li>
<li><p>Both sides agree to talk</p>
</li>
<li><p>Rules are decided</p>
</li>
</ul>
<p>Only then does actual data transfer begin.</p>
<p>This agreement process is called the <strong>TCP 3-Way Handshake</strong>.</p>
<h2 id="heading-what-is-the-tcp-3-way-handshake">What Is the TCP 3-Way Handshake?</h2>
<p>The <strong>3-Way Handshake</strong> is the process by which:</p>
<ul>
<li><p>A TCP connection is <strong>established</strong></p>
</li>
<li><p>Both client and server confirm:</p>
<ul>
<li><p>“I am ready”</p>
</li>
<li><p>“I can hear you”</p>
</li>
<li><p>“Let’s start communication”</p>
</li>
</ul>
</li>
</ul>
<p>It has <strong>three steps</strong>:</p>
<ol>
<li><p>SYN</p>
</li>
<li><p>SYN-ACK</p>
</li>
<li><p>ACK</p>
</li>
</ol>
<p>Think of it as a <strong>polite conversation</strong>.</p>
<h2 id="heading-working-of-tcp-3-way-handshake-clear-explanation">Working of TCP 3-Way Handshake (Clear Explanation)</h2>
<p>Before two computers can send data to each other on the internet, they must first <strong>establish a connection</strong>.<br />They cannot start sending data randomly. Both sides need to confirm that the other is ready.</p>
<p>TCP does this using a process called the <strong>3-Way Handshake</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1693845931255/f643190a-25d0-4d26-9095-951ef5d13707.png" alt /></p>
<h3 id="heading-step-1-hey-are-you-there-syn">Step 1: <em>Hey, Are You There?</em> - SYN</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1693846412502/e698c308-d4ab-402b-b212-1fd2df78ce28.png" alt /></p>
<p>Imagine you want to talk to your friend using a walkie-talkie.</p>
<p>Before you start speaking, you press the button and say:</p>
<blockquote>
<p><strong>Hey, are you there?</strong></p>
</blockquote>
<p>This is exactly what happens in the first step of TCP.</p>
<ul>
<li><p>The <strong>client</strong> sends a message to the <strong>server</strong></p>
</li>
<li><p>This message is called <strong>SYN</strong> (Synchronize)</p>
</li>
<li><p>It means:<br />  <strong>I want to start a connection with you.</strong></p>
</li>
</ul>
<p>Along with SYN, the client also sends a <strong>sequence number</strong>, usually starting from <strong>SEQ = 0</strong>.</p>
<p>You can think of this sequence number as:</p>
<ul>
<li><p>A starting page number of a notebook</p>
</li>
<li><p>Or a reference point for future messages</p>
</li>
</ul>
<p><strong>At this stage:</strong></p>
<ul>
<li><p>No real data is sent</p>
</li>
<li><p>Only a connection request is made</p>
</li>
</ul>
<h3 id="heading-step-2-yes-im-here-syn-ack">Step 2: <em>Yes, I’m Here!</em> - SYN + ACK</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1693846450173/51c105df-4082-4d9c-851f-98e0f3a044d4.png" alt /></p>
<p>Now imagine your friend hears your message and replies:</p>
<blockquote>
<p><strong>Yes, I’m here. I heard you. Can you hear me too?</strong></p>
</blockquote>
<p>This is the second step of the TCP handshake.</p>
<ul>
<li><p>The <strong>server</strong> replies to the client</p>
</li>
<li><p>It sends a message with <strong>SYN + ACK</strong></p>
</li>
</ul>
<p>This means two things:</p>
<ul>
<li><p><strong>ACK</strong>: I received your SYN</p>
</li>
<li><p><strong>SYN</strong>: I also want to start communication with you</p>
</li>
</ul>
<p>The server also sends:</p>
<ul>
<li><p>Its own <strong>sequence number</strong> (for example, SEQ = 0)</p>
</li>
<li><p>An acknowledgment number <strong>ACK = 1</strong>, meaning:</p>
<blockquote>
<p>I received your sequence number 0, now I expect 1 next</p>
</blockquote>
</li>
</ul>
<p><strong>Now both sides know:</strong></p>
<ul>
<li><p>The other system exists</p>
</li>
<li><p>The connection path works</p>
</li>
<li><p>Sequence numbers are exchanged</p>
</li>
</ul>
<h3 id="heading-step-3-yes-lets-start-talking-ack">Step 3: <em>Yes, Let’s Start Talking</em> - ACK</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1693846480334/3a7441c0-15ce-4e79-a988-f6c8060a11ac.png" alt /></p>
<p>Finally, you reply to your friend:</p>
<blockquote>
<p><strong>Yes, I can hear you too. Let’s talk.</strong></p>
</blockquote>
<p>This is the last step of the TCP handshake.</p>
<ul>
<li><p>The <strong>client</strong> sends an <strong>ACK</strong> message to the server</p>
</li>
<li><p>It confirms:</p>
<blockquote>
<p>I received your SYN and your sequence number</p>
</blockquote>
</li>
</ul>
<p>The client now sends:</p>
<ul>
<li><p><strong>ACK = 1</strong></p>
</li>
<li><p><strong>SEQ = 1</strong></p>
</li>
</ul>
<p><strong>At this point:</strong></p>
<ul>
<li><p>Both client and server fully trust the connection</p>
</li>
<li><p>Both know the starting sequence numbers</p>
</li>
<li><p>The connection is officially established</p>
</li>
</ul>
<h3 id="heading-tcp-3-way-handshake-completed">TCP 3-Way Handshake Completed</h3>
<p>After these three steps:</p>
<ol>
<li><p>SYN</p>
</li>
<li><p>SYN-ACK</p>
</li>
<li><p>ACK</p>
</li>
</ol>
<p>The TCP connection is <strong>successfully established</strong>, and now:</p>
<ul>
<li><p>Actual data transfer can begin</p>
</li>
<li><p>Data can be sent reliably</p>
</li>
<li><p>Packets can be tracked using sequence numbers</p>
</li>
</ul>
<h3 id="heading-why-this-handshake-is-important">Why This Handshake Is Important</h3>
<p>The TCP 3-Way Handshake ensures that:</p>
<ul>
<li><p>Both computers are ready</p>
</li>
<li><p>Data won’t be sent into the void</p>
</li>
<li><p>Sequence numbers are synchronized</p>
</li>
<li><p>Communication starts in a controlled and reliable way</p>
</li>
</ul>
<p>Without this handshake:</p>
<ul>
<li><p>Data could be lost</p>
</li>
<li><p>Messages could arrive out of order</p>
</li>
<li><p>Communication would be unreliable</p>
</li>
</ul>
<h2 id="heading-how-data-transfer-works-in-tcp">How Data Transfer Works in TCP</h2>
<p>Once the connection is established:</p>
<ul>
<li><p>Data is broken into <strong>small packets</strong></p>
</li>
<li><p>Each packet has:</p>
<ul>
<li><p>Sequence number</p>
</li>
<li><p>Data</p>
</li>
</ul>
</li>
<li><p>Receiver sends <strong>ACK</strong> for received packets</p>
</li>
</ul>
<p>Example:</p>
<pre><code class="lang-plaintext">Packet 1 → ACK 1
Packet 2 → ACK 2
Packet 3 → ACK 3
</code></pre>
<p>If ACK is missing → sender knows something went wrong.</p>
<h2 id="heading-what-are-sequence-numbers">What Are Sequence Numbers ?</h2>
<p>Sequence numbers help TCP:</p>
<ul>
<li><p>Keep data in correct order</p>
</li>
<li><p>Detect missing packets</p>
</li>
</ul>
<p>Example:</p>
<pre><code class="lang-plaintext">Sent packets: 1, 2, 3, 4
Received: 1, 2, 4
Missing: 3
</code></pre>
<p>TCP notices packet 3 is missing and asks for it again.</p>
<h2 id="heading-how-tcp-ensures-reliability">How TCP Ensures Reliability</h2>
<p>TCP is reliable because it uses:</p>
<h3 id="heading-1-acknowledgements-acks">1. Acknowledgements (ACKs)</h3>
<p>Receiver confirms each packet.</p>
<h3 id="heading-2-retransmission">2. Retransmission</h3>
<p>If ACK is not received, packet is sent again.</p>
<h3 id="heading-3-ordered-delivery">3. Ordered Delivery</h3>
<p>Sequence numbers ensure correct order.</p>
<h3 id="heading-4-error-checking">4. Error Checking</h3>
<p>Corrupted packets are discarded and resent.</p>
<h2 id="heading-handling-packet-loss">Handling Packet Loss</h2>
<p>Let’s say:</p>
<ul>
<li><p>Packet 5 is lost</p>
</li>
<li><p>Receiver keeps sending ACK for packet 4</p>
</li>
</ul>
<p>Sender understands:</p>
<blockquote>
<p>Packet 5 did not reach</p>
</blockquote>
<p>Sender resends packet 5.</p>
<p>This is called <strong><mark>retransmission</mark></strong><mark>.</mark></p>
<h2 id="heading-as-a-web-developer-tcp-matters-because">As a web developer, TCP matters because:</h2>
<ul>
<li><p>HTTP runs on top of TCP</p>
</li>
<li><p>Login systems depend on TCP reliability</p>
</li>
<li><p>APIs require ordered, correct data</p>
</li>
<li><p>Databases depend on TCP connections</p>
</li>
</ul>
<p>Without TCP:</p>
<ul>
<li><p>Forms would submit incorrectly</p>
</li>
<li><p>Pages would load half-broken</p>
</li>
<li><p>APIs would fail randomly</p>
</li>
</ul>
<h3 id="heading-want-more"><strong>Want More…?</strong></h3>
<p>I write articles on <a target="_blank" href="https://blog.prakashtsx.me/">blog.prakashtsx.com</a> and also post development-related content on the following platforms:</p>
<ul>
<li><p><a target="_blank" href="https://x.com/prakashtsx"><strong>Twitter/X</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/prakashtsx"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[TCP vs UDP vs HTTP]]></title><description><![CDATA[Why the Internet Needs Rules to Send Data
Imagine the internet as a huge city.

Millions of people (devices)

Sending messages every second

Across different roads (networks)


If everyone just shouted messages randomly, nothing would work.
So the in...]]></description><link>https://blog.prakashtsx.me/tcp-udp</link><guid isPermaLink="true">https://blog.prakashtsx.me/tcp-udp</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Thu, 29 Jan 2026 18:32:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769711132765/0056923e-0f34-44fc-b306-6b3898ceb22d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-why-the-internet-needs-rules-to-send-data">Why the Internet Needs Rules to Send Data</h2>
<p>Imagine the internet as a <strong>huge city</strong>.</p>
<ul>
<li><p>Millions of people (devices)</p>
</li>
<li><p>Sending messages every second</p>
</li>
<li><p>Across different roads (networks)</p>
</li>
</ul>
<p>If everyone just shouted messages randomly, nothing would work.</p>
<p><strong>So the internet needs rules</strong><br />These rules are called <strong>protocols</strong>.</p>
<p>At a very high level:</p>
<ul>
<li><p><strong>TCP and UDP</strong> decide <em>how data travels</em></p>
</li>
<li><p><strong>HTTP</strong> decides <em>what the data means</em></p>
</li>
</ul>
<h2 id="heading-what-are-tcp-and-udp">What Are TCP and UDP ?</h2>
<p><strong>TCP</strong> and <strong>UDP</strong> are <strong>transport protocols</strong>.</p>
<p>Their job is simple:</p>
<blockquote>
<p>Move data from one computer to another.</p>
</blockquote>
<p>But they do it <strong>very differently</strong>.</p>
<h3 id="heading-tcp-transmission-control-protocol">TCP (Transmission Control Protocol)</h3>
<ul>
<li><p>Safe</p>
</li>
<li><p>Reliable</p>
</li>
<li><p>Slower</p>
</li>
<li><p>Makes sure nothing is lost</p>
</li>
</ul>
<h3 id="heading-udp-user-datagram-protocol">UDP (User Datagram Protocol)</h3>
<ul>
<li><p>Fast</p>
</li>
<li><p>No guarantees</p>
</li>
<li><p>Risky</p>
</li>
<li><p>Sends data and moves on</p>
</li>
</ul>
<h2 id="heading-easy-example-to-understand-with-real">Easy Example to understand with real :</h2>
<h3 id="heading-tcp-courier-service">TCP = Courier Service</h3>
<ul>
<li><p>Package is tracked</p>
</li>
<li><p>Signature required</p>
</li>
<li><p>If lost → resend</p>
</li>
<li><p>Delivery guaranteed</p>
</li>
</ul>
<h3 id="heading-udp-public-announcement">UDP = Public Announcement</h3>
<ul>
<li><p>Message is broadcast</p>
</li>
<li><p>No confirmation</p>
</li>
<li><p>If someone misses it → too bad</p>
</li>
<li><p>Very fast</p>
</li>
</ul>
<h2 id="heading-key-differences-between-tcp-and-udp">Key Differences Between TCP and UDP</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>TCP</td><td>UDP</td></tr>
</thead>
<tbody>
<tr>
<td>Reliability</td><td>Guaranteed</td><td>Not guaranteed</td></tr>
<tr>
<td>Speed</td><td>Slower</td><td>Faster</td></tr>
<tr>
<td>Order of data</td><td>Maintained</td><td>Not guaranteed</td></tr>
<tr>
<td>Error checking</td><td>Yes</td><td>Minimal</td></tr>
<tr>
<td>Connection</td><td>Required</td><td>Not required</td></tr>
</tbody>
</table>
</div><h2 id="heading-when-to-use-tcp">When to Use TCP</h2>
<p>Use <strong>TCP</strong> when <strong>accuracy matters more than speed</strong>.</p>
<h3 id="heading-examples">Examples:</h3>
<ul>
<li><p>Loading a website</p>
</li>
<li><p>Sending emails</p>
</li>
<li><p>File downloads</p>
</li>
<li><p>Online banking</p>
</li>
<li><p>APIs and backend services</p>
</li>
</ul>
<blockquote>
<p>If losing data is unacceptable → use TCP</p>
</blockquote>
<h2 id="heading-when-to-use-udp">When to Use UDP</h2>
<p>Use <strong>UDP</strong> when <strong>speed matters more than perfection</strong>.</p>
<h3 id="heading-examples-1">Examples:</h3>
<ul>
<li><p>Live video streaming</p>
</li>
<li><p>Online gaming</p>
</li>
<li><p>Voice calls (Zoom, WhatsApp)</p>
</li>
<li><p>DNS queries</p>
</li>
</ul>
<blockquote>
<p>If small data loss is okay → use UDP</p>
</blockquote>
<h2 id="heading-examples-easy-to-remember">Examples (Easy to Remember)</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Use Case</td><td>Protocol</td></tr>
</thead>
<tbody>
<tr>
<td>Web browsing</td><td>TCP</td></tr>
<tr>
<td>Email</td><td>TCP</td></tr>
<tr>
<td>File download</td><td>TCP</td></tr>
<tr>
<td>Video call</td><td>UDP</td></tr>
<tr>
<td>Online gaming</td><td>UDP</td></tr>
<tr>
<td>Live sports stream</td><td>UDP</td></tr>
</tbody>
</table>
</div><h2 id="heading-what-is-http">What is HTTP ?</h2>
<p><strong>HTTP = HyperText Transfer Protocol</strong></p>
<p>HTTP is <strong>NOT</strong> responsible for sending data across the network.</p>
<p>Instead, HTTP defines:</p>
<ul>
<li><p>Requests (GET, POST, etc.)</p>
</li>
<li><p>Responses (status codes, headers, body)</p>
</li>
<li><p>How browsers talk to servers</p>
</li>
</ul>
<p><strong>HTTP lives at the application level</strong></p>
<h2 id="heading-where-http-fits">Where HTTP Fits ?</h2>
<p>Think in layers:</p>
<pre><code class="lang-plaintext">HTTP  → What to say
TCP   → How to send safely
IP    → Where to send
</code></pre>
<p>So:</p>
<ul>
<li><p>HTTP decides <em>what the message looks like</em></p>
</li>
<li><p>TCP decides <em>how it reaches safely</em></p>
</li>
</ul>
<h2 id="heading-relationship-between-tcp-and-http">Relationship Between TCP and HTTP</h2>
<ul>
<li><p>HTTP <strong>runs on top of TCP</strong></p>
</li>
<li><p>HTTP <strong>depends on TCP</strong></p>
</li>
<li><p>TCP handles reliability</p>
</li>
<li><p>HTTP focuses on content and rules</p>
</li>
</ul>
<h3 id="heading-example-flow">Example Flow:</h3>
<ol>
<li><p>Browser creates HTTP request</p>
</li>
<li><p>TCP creates a connection</p>
</li>
<li><p>Data is sent safely</p>
</li>
<li><p>Server replies via TCP</p>
</li>
<li><p>Browser reads HTTP response</p>
</li>
</ol>
<h2 id="heading-why-http-does-not-replace-tcp">Why HTTP Does NOT Replace TCP ?</h2>
<blockquote>
<p>HTTP sends data, so why do we need TCP?</p>
</blockquote>
<p>Because:</p>
<ul>
<li><p>HTTP <strong>doesn’t handle delivery</strong></p>
</li>
<li><p>HTTP <strong>doesn’t handle retries</strong></p>
</li>
<li><p>HTTP <strong>doesn’t handle packet loss</strong></p>
</li>
</ul>
<p>HTTP <strong>assumes</strong> TCP is already doing that job.</p>
<h2 id="heading-simplified-layering-tcpip-model">Simplified Layering (TCP/IP Model)</h2>
<pre><code class="lang-plaintext">Application Layer → HTTP
Transport Layer   → TCP / UDP
Internet Layer    → IP
Network Layer     → Physical network
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Getting Started with cURL]]></title><description><![CDATA[If you are learning backend development, APIs, or even basic web concepts, you will hear the word cURL again and again. At first it looks scary a black terminal, strange commands, and confusing responses.
This blog is written to remove that fear.
No ...]]></description><link>https://blog.prakashtsx.me/curl-basic</link><guid isPermaLink="true">https://blog.prakashtsx.me/curl-basic</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[curl]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Wed, 28 Jan 2026 19:10:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769627318753/903bea81-4a86-4510-a783-dbbaf160674a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you are learning backend development, APIs, or even basic web concepts, you will hear the word <strong>cURL</strong> again and again. At first it looks scary a black terminal, strange commands, and confusing responses.</p>
<p>This blog is written to <strong>remove that fear</strong>.</p>
<p>No overload. Just clear thinking.</p>
<h3 id="heading-before-curl-what-is-a-server">❀ Before cURL: What is a Server?</h3>
<p>⤷ A <strong>server</strong> is simply a computer that is always connected to the internet and waits for requests.</p>
<p>Examples of what servers do:</p>
<ul>
<li><p>Send a webpage (HTML, CSS, JS)</p>
</li>
<li><p>Return user data from a database</p>
</li>
<li><p>Accept form submissions</p>
</li>
<li><p>Provide APIs for mobile apps</p>
</li>
</ul>
<p>Whenever you:</p>
<ul>
<li><p>Open a website</p>
</li>
<li><p>Submit a login form</p>
</li>
<li><p>Scroll Instagram</p>
</li>
</ul>
<p>You are <strong>talking to a server</strong>.</p>
<h2 id="heading-how-do-we-talk-to-a-server">❀ How Do We Talk to a Server?</h2>
<p>⤑ To talk to a server, we send a <strong>request</strong>.</p>
<p>That request contains:</p>
<ul>
<li><p>What we want (data, page, action)</p>
</li>
<li><p>Where we want it from (URL)</p>
</li>
<li><p>Sometimes extra data (login info, form data)</p>
</li>
</ul>
<p>⤑ The server then sends back a <strong>response</strong>.</p>
<p>That response contains:</p>
<ul>
<li><p>Status (success or failure)</p>
</li>
<li><p>Data (HTML, JSON, text, etc.)</p>
</li>
</ul>
<h2 id="heading-where-does-curl-come-in">❀ Where Does cURL Come In?</h2>
<p>⤷ Normally, browsers send requests for us.</p>
<p>But programmers often want to:</p>
<ul>
<li><p>Test APIs</p>
</li>
<li><p>Debug backend issues</p>
</li>
<li><p>Call a server without a browser</p>
</li>
<li><p>Automate requests</p>
</li>
</ul>
<p>This is where <strong>cURL</strong> is used.</p>
<p>⤑ <strong>cURL is a tool that lets you send requests to a server from the terminal.</strong></p>
<p>Think of it as:</p>
<p><strong>Terminal → Server → Response</strong></p>
<h2 id="heading-what-is-curl">❀ What is cURL ?</h2>
<p>⤑ <strong>cURL = Command Line URL tool</strong></p>
<p>⤑ <strong>cURL</strong> is a way to send messages to a server using text commands.</p>
<p>No UI. No buttons. Just pure communication.</p>
<h2 id="heading-why-programmers-need-curl">❀ Why Programmers Need cURL ?</h2>
<p>⤷ Programmers use cURL because:</p>
<ul>
<li><p>It works everywhere (Linux, Mac, Windows)</p>
</li>
<li><p>No browser required</p>
</li>
<li><p>Perfect for backend and API testing</p>
</li>
<li><p>Helps understand how HTTP really works</p>
</li>
</ul>
<h2 id="heading-understanding-request-and-response">❀ Understanding Request and Response</h2>
<h3 id="heading-request-what-you-send">⤑ Request (What You Send)</h3>
<p>A basic HTTP request includes:</p>
<ul>
<li><p>Method (GET / POST)</p>
</li>
<li><p>URL</p>
</li>
<li><p>Headers (optional for now)</p>
</li>
<li><p>Body (only for POST)</p>
</li>
</ul>
<p>Example :</p>
<p>GET / HTTP/1.1</p>
<p>Host: <a target="_blank" href="http://prakashtsx.me">prakashtsx.me</a></p>
<h3 id="heading-response-what-you-get-back">⤑ Response (What You Get Back)</h3>
<p>A response includes:</p>
<ul>
<li><p>Status code (200, 404, 500)</p>
</li>
<li><p>Headers</p>
</li>
<li><p>Data (HTML, JSON, text)</p>
</li>
</ul>
<p>Example :</p>
<p>HTTP/1.1 200 OK</p>
<p>Content-Type: text/html</p>
<p>&lt;html&gt;...&lt;/html&gt;</p>
<h2 id="heading-status-codes">❀ Status Codes :</h2>
<ul>
<li><p><strong>200</strong> → Success</p>
</li>
<li><p><strong>404</strong> → Not Found</p>
</li>
<li><p><strong>500</strong> → Server Error</p>
</li>
</ul>
<h2 id="heading-using-curl-to-talk-to-apis">❀ Using cURL to Talk to APIs</h2>
<p>APIs usually return <strong>JSON</strong>, not HTML.</p>
<p>Example:</p>
<p>curl <a target="_blank" href="https://api.github.com">https://api.github.com</a></p>
<p>We will see JSON data in response.</p>
<p>This is how:</p>
<ul>
<li><p>Frontend talks to backend</p>
</li>
<li><p>Mobile apps talk to servers</p>
</li>
<li><p>Services talk to other services</p>
</li>
</ul>
<h2 id="heading-get-vs-post-only-what-we-need">❀ GET vs POST (Only What We Need)</h2>
<h3 id="heading-get">⤷ GET</h3>
<ul>
<li><p>Used to <strong>fetch data</strong></p>
</li>
<li><p>Default method in cURL</p>
</li>
</ul>
<p>curl <a target="_blank" href="https://api.example.com/users">https://api.example.com/users</a></p>
<h3 id="heading-post">⤷ POST</h3>
<ul>
<li>Used to <strong>send data</strong></li>
</ul>
<p>curl -X POST <a target="_blank" href="https://api.example.com/login">https://api.example.com/login</a></p>
<h2 id="heading-browser-request-vs-curl-request-conceptual">❀ Browser Request vs cURL Request (Conceptual)</h2>
<p><strong>Browser:</strong></p>
<ul>
<li>UI + request + rendering</li>
</ul>
<p><strong>cURL:</strong></p>
<ul>
<li>Only request + response</li>
</ul>
<p>Same protocol. Same server. Different interface.</p>
<h2 id="heading-where-curl-fits-in-backend-development">❀ Where cURL Fits in Backend Development</h2>
<p>cURL helps you:</p>
<ul>
<li><p>Test APIs before frontend exists</p>
</li>
<li><p>Debug server issues</p>
</li>
<li><p>Understand HTTP deeply</p>
</li>
<li><p>Think like a backend engineer</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How DNS Resolution Works]]></title><description><![CDATA[❀ Introduction :
⤷ Every time you type google.com in your browser, something important happens in the background.Your computer does not understand website names. It only understands IP addresses.
⤑ DNS (Domain Name System) helps convert:
google.com →...]]></description><link>https://blog.prakashtsx.me/dns-resolution</link><guid isPermaLink="true">https://blog.prakashtsx.me/dns-resolution</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[dns]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Sat, 24 Jan 2026 13:27:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769260726770/100f2102-0a59-4709-bb3e-3ef87d059ce8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction">❀ Introduction :</h3>
<p>⤷ Every time you type <a target="_blank" href="http://google.com"><strong>google.com</strong></a> in your browser, something important happens in the background.<br />Your computer does <strong>not understand website names</strong>. It only understands <strong>IP addresses</strong>.</p>
<p>⤑ DNS (Domain Name System) helps convert:</p>
<pre><code class="lang-plaintext">google.com → IP address
</code></pre>
<p>⤑ That is why DNS is called the <strong>internet’s phonebook</strong>.</p>
<p>⤑ In this blog, we will understand <strong>how DNS works step by step</strong> using a tool called <code>dig</code>.</p>
<h3 id="heading-what-is-dns-and-why-do-we-need-it">❋ What is DNS and Why Do We Need It?</h3>
<p>⤑ Humans like easy names:</p>
<ul>
<li><p><a target="_blank" href="http://google.com">google.com</a></p>
</li>
<li><p><a target="_blank" href="http://amazon.com">amazon.com</a></p>
</li>
<li><p><a target="_blank" href="http://github.com">github.com</a></p>
</li>
</ul>
<p>⤑ Computers like numbers:</p>
<ul>
<li>142.250.185.46</li>
</ul>
<p>⤑ Without DNS:</p>
<ul>
<li><p>You would need to remember IP addresses</p>
</li>
<li><p>Websites changing servers would break bookmarks</p>
</li>
</ul>
<p>⤑ DNS solves this by:</p>
<ul>
<li><p>Mapping domain names to IP addresses</p>
</li>
<li><p>Working in a <strong>distributed way</strong>, not from one single server</p>
</li>
<li><p>Making the internet <strong>fast, scalable, and reliable</strong></p>
</li>
</ul>
<h3 id="heading-what-is-dig-and-why-is-it-used">❋ What is <code>dig</code> and Why Is It Used?</h3>
<p>⤑ <code>dig</code> stands for <strong>Domain Information Groper</strong>.</p>
<p>⤑ It is a command-line tool used to:</p>
<ul>
<li><p>Check DNS records</p>
</li>
<li><p>Understand how DNS resolution works</p>
</li>
<li><p>Debug DNS problems</p>
</li>
<li><p>Learn DNS deeply</p>
</li>
</ul>
<p>Basic command:</p>
<pre><code class="lang-plaintext">dig google.com
</code></pre>
<p>Unlike browsers (which hide DNS details), <code>dig</code> shows <strong>exactly what is happening</strong>.</p>
<h3 id="heading-dns-works-in-layers-hierarchy">❋ DNS Works in Layers (Hierarchy)</h3>
<p>DNS is not one server.<br />It works in <strong>three main layers</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769256793541/78a966a6-cd37-4eec-8721-39e8459311f2.png" alt class="image--center mx-auto" /></p>
<p>Each layer only knows <strong>the next layer</strong>, not everything.</p>
<h3 id="heading-layer-1-root-name-servers-dig-ns">❋ Layer 1 : Root Name Servers (<code>dig . NS</code>)</h3>
<p>Command:</p>
<pre><code class="lang-plaintext">dig . NS
</code></pre>
<p>This asks:</p>
<p>Who manages the root of DNS?</p>
<p><strong>What root servers do:</strong></p>
<ul>
<li><p>They are the top of DNS</p>
</li>
<li><p>They do NOT know website IPs</p>
</li>
<li><p>They only know where TLD servers are</p>
</li>
</ul>
<p>Example response idea:</p>
<p>I don’t know <a target="_blank" href="http://google.com">google.com</a>, but I know who manages <code>.com</code></p>
<p>Important points:</p>
<ul>
<li><p>There are <strong>13 root server names</strong></p>
</li>
<li><p>They are spread across the world</p>
</li>
<li><p>Very reliable and fast</p>
</li>
</ul>
<h3 id="heading-layer-2-tld-name-servers-dig-com-ns">❋ Layer 2 : TLD Name Servers (<code>dig com NS</code>)</h3>
<p>Command:</p>
<pre><code class="lang-plaintext">dig com NS
</code></pre>
<p>This asks:</p>
<p>Who manages the <code>.com</code> domain?</p>
<p><strong>What TLD servers do:</strong></p>
<ul>
<li><p>They manage domains like <code>.com</code>, <code>.org</code>, <code>.net</code></p>
</li>
<li><p>They do NOT know IP addresses</p>
</li>
<li><p>They point to <strong>authoritative servers</strong></p>
</li>
</ul>
<p>Example response idea:</p>
<p><em>I don’t know google’s IP, but I know Google’s name servers</em></p>
<h3 id="heading-layer-3-authoritative-name-servers-dig-googlecomhttpgooglecom-ns">❋ Layer 3 : Authoritative Name Servers (<code>dig</code> <a target="_blank" href="http://google.com"><code>google.com</code></a> <code>NS</code>)</h3>
<p>Command:</p>
<pre><code class="lang-plaintext">dig google.com NS
</code></pre>
<p>This asks:</p>
<p><em>Who is responsible for</em> <a target="_blank" href="http://google.com"><em>google.com</em></a><em>?</em></p>
<p><strong>Authoritative servers:</strong></p>
<ul>
<li><p>Are owned by the domain owner (Google)</p>
</li>
<li><p>Store real DNS records</p>
</li>
<li><p>Are the <strong>source of truth</strong></p>
</li>
</ul>
<p>They contain:</p>
<ul>
<li><p>A records (IP address)</p>
</li>
<li><p>MX records (email)</p>
</li>
<li><p>TXT records (verification)</p>
</li>
</ul>
<p>Example:</p>
<pre><code class="lang-plaintext">ns1.google.com
ns2.google.com
</code></pre>
<p>These servers finally know:</p>
<p><em>Yes, this is the IP address of</em> <a target="_blank" href="http://google.com"><em>google.com</em></a></p>
<h3 id="heading-full-dns-resolution-dig-googlecomhttpgooglecom">❋ Full DNS Resolution (<code>dig</code> <a target="_blank" href="http://google.com"><code>google.com</code></a>)</h3>
<p>Command:</p>
<pre><code class="lang-plaintext">dig google.com
</code></pre>
<p>This gives:</p>
<ul>
<li><p>IP address</p>
</li>
<li><p>TTL (how long it can be cached)</p>
</li>
<li><p>Which DNS server answered</p>
</li>
</ul>
<h3 id="heading-what-happens-behind-the-scenes">⤑ What happens behind the scenes:</h3>
<ol>
<li><p>Check cache</p>
</li>
<li><p>Ask root server</p>
</li>
<li><p>Root points to <code>.com</code></p>
</li>
<li><p><code>.com</code> points to Google servers</p>
</li>
<li><p>Google server returns IP</p>
</li>
<li><p>Result is cached</p>
</li>
</ol>
<p>TTL example:</p>
<pre><code class="lang-plaintext">300 seconds
</code></pre>
<p>Means the result can be reused for 5 minutes.</p>
<h3 id="heading-what-are-ns-records-and-why-are-they-important">❋ What Are NS Records and Why Are They Important?</h3>
<p>⤷ <strong>NS (Name Server) records</strong> tell:</p>
<ul>
<li><p>Who controls a domain</p>
</li>
<li><p>Where DNS queries should go next</p>
</li>
</ul>
<p>⤑ They are important because:</p>
<ul>
<li><p>DNS is distributed</p>
</li>
<li><p>No single server controls everything</p>
</li>
<li><p>Multiple servers give backup (redundancy)</p>
</li>
</ul>
<p>If one server fails, another works.</p>
<h3 id="heading-what-is-a-recursive-resolver">❋ What is a Recursive Resolver?</h3>
<p>⤷ Your computer does not talk to root servers directly.</p>
<p>⤑ Instead, it uses a <strong>recursive resolver</strong>, such as:</p>
<ul>
<li><p>8.8.8.8 (Google DNS)</p>
</li>
<li><p>1.1.1.1 (Cloudflare DNS)</p>
</li>
<li><p>ISP DNS</p>
</li>
</ul>
<p>Flow:</p>
<pre><code class="lang-plaintext">Your PC → Recursive Resolver → Root → TLD → Authoritative
</code></pre>
<p>⤑ The resolver:</p>
<ul>
<li><p>Does all DNS work for you</p>
</li>
<li><p>Caches results</p>
</li>
<li><p>Returns final IP</p>
</li>
</ul>
<h3 id="heading-dns-and-real-browser-requests">❋ DNS and Real Browser Requests</h3>
<p>⤷ When you open a website:</p>
<ol>
<li><p>Browser checks cache</p>
</li>
<li><p>OS checks cache</p>
</li>
<li><p>Recursive resolver is asked</p>
</li>
<li><p>DNS resolution happens</p>
</li>
<li><p>IP address is returned</p>
</li>
<li><p>Browser connects using HTTP/HTTPS</p>
</li>
</ol>
<p>⤑ DNS usually takes:</p>
<ul>
<li><p><strong>20–120 ms</strong> if not cached</p>
</li>
<li><p><strong>&lt;10 ms</strong> if cached</p>
</li>
</ul>
<p>That’s why DNS feels instant.</p>
<h3 id="heading-dns-from-a-system-design-view">❋ DNS from a System Design View</h3>
<h3 id="heading-dns-is-designed-to-be">⤑ <em>DNS is designed to be:</em></h3>
<ul>
<li><p>Distributed</p>
</li>
<li><p>Fast</p>
</li>
<li><p>Fault-tolerant</p>
</li>
<li><p>Scalable</p>
</li>
</ul>
<p>⤑ Important ideas:</p>
<ul>
<li><p>Caching improves speed</p>
</li>
<li><p>Multiple name servers improve reliability</p>
</li>
<li><p>DNS helps CDNs route users to nearby servers</p>
</li>
</ul>
<h3 id="heading-you-can-watch-for-system-design-view-of-dns"><em>You can watch for System Design View of DNS :</em></h3>
<iframe width="560" height="315" src="https://www.youtube.com/embed/27r4Bzuj5NQ?si=UZ5DqYK9k1qU2yYA"></iframe>]]></content:encoded></item><item><title><![CDATA[DNS Record Types Explained]]></title><description><![CDATA[⤷ When you type any website like take my personal website as an example : prakashtsx.me . How does your browser know where that website actually lives ?
Probably you will say it lives at domain address like .com .in or any other domain .
But that not...]]></description><link>https://blog.prakashtsx.me/dns-records</link><guid isPermaLink="true">https://blog.prakashtsx.me/dns-records</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[dns]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Wed, 21 Jan 2026 17:41:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769017142438/c8611125-bc07-4e80-a2d7-804850711fdc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>⤷ When you type any website like take my personal website as an example : <a target="_blank" href="http://prakashtsx.me">prakashtsx.me</a> . How does your browser know where that website actually lives ?</p>
<p>Probably you will say it lives at domain address like .com .in or any other domain .</p>
<p><strong><em>But that not the case .</em></strong></p>
<p>⤑ You know A domain name is only a <strong>name</strong> , not an address.</p>
<p>⤑ Your browser needs the real server address (as IP address) to load a website.</p>
<p>⤑ This is where DNS (Domain Name System) comes in .</p>
<p>✢ DNS is the <strong>phonebook of the Internet</strong>.<br />⤑ It translates human-friendly names into machine-friendly addresses, so browsers can find the correct server.</p>
<p>✢ In this article, we will learn exactly how DNS works and what each DNS record does using real examples from my website :</p>
<ul>
<li><p><a target="_blank" href="http://prakashtsx.me"><strong>prakashtsx.me</strong></a></p>
</li>
<li><p><a target="_blank" href="http://blog.prakashtsx.me"><strong>blog.prakashtsx.me</strong></a></p>
</li>
</ul>
<hr />
<h3 id="heading-1-what-dns-is">1. What DNS Is ?</h3>
<p>⤷ Imagine you want to visit a friend’s house.</p>
<p>You know their <strong>name</strong>, but not their <strong>address</strong>.</p>
<p>So you check your phone contacts → the contact shows the <strong>address</strong> → you travel there.</p>
<p>✢ DNS works the same way.</p>
<ul>
<li><p>You type <a target="_blank" href="http://prakashtsx.me"><strong>prakashtsx.me</strong></a></p>
</li>
<li><p>Your browser doesn’t know the IP</p>
</li>
<li><p>DNS tells the browser the correct server address</p>
</li>
<li><p>Browser loads the website</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769012646444/2588c941-e3a0-45b9-8f3f-dea86b8a7e43.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-2-why-dns-records-are-needed">2. Why DNS Records Are Needed ?</h3>
<p>⤷ A domain is not just a website.<br />It can have:</p>
<ul>
<li><p>Subdomains (<a target="_blank" href="http://blog.prakashtsx.me">blog.prakashtsx.me</a>)</p>
</li>
<li><p>Email servers</p>
</li>
<li><p>Verification settings</p>
</li>
<li><p>Aliases</p>
</li>
<li><p>IPv4 and IPv6 addresses</p>
</li>
<li><p>Name servers (authoritative DNS)</p>
</li>
</ul>
<p>⤑ To manage all of this, DNS uses <strong>different record types</strong>, each with a specific purpose.</p>
<p>⤑ Think of DNS as a file with different sections:</p>
<ul>
<li><p>One section says : This domain belongs to this server.</p>
</li>
<li><p>Another says : This is the mail server.</p>
</li>
<li><p>Another says : This subdomain points here.</p>
</li>
</ul>
<p>These sections are called <strong>DNS Records</strong>.</p>
<h3 id="heading-3-ns-record-name-server-record"><strong>3. NS Record (Name Server Record)</strong></h3>
<p><strong>Who is responsible for this domain?</strong></p>
<p>⤷ NS records tell the world <strong>which DNS servers contain the real (authoritative) information</strong> for a domain.</p>
<h3 id="heading-you-used-the-command"><strong>You used the command:</strong></h3>
<pre><code class="lang-plaintext">nslookup -type=ns prakashtsx.me
</code></pre>
<h3 id="heading-the-dns-resolver-replied-with"><strong>The DNS resolver replied with:</strong></h3>
<pre><code class="lang-plaintext">prakashtsx.me  nameserver = dns1.registrar-servers.com
prakashtsx.me  nameserver = dns2.registrar-servers.com
</code></pre>
<h3 id="heading-what-this-means">✢ What this means:</h3>
<p>⤷ <em>These two servers are the “authoritative DNS servers” for your domain.</em></p>
<p>In simple words:</p>
<p><em>They are the official place where the REAL DNS records of prakashtsx.me live.</em></p>
<p>⤑ If the entire internet wants to know:</p>
<ul>
<li><p>What is the A record of <a target="_blank" href="http://prakashtsx.me">prakashtsx.me</a>?</p>
</li>
<li><p>What is the MX record?</p>
</li>
<li><p>What is the CNAME for <a target="_blank" href="http://blog.prakashtsx.me">blog.prakashtsx.me</a>?</p>
</li>
<li><p>What are the TXT verification records?</p>
</li>
</ul>
<p>They will <strong>ask these two servers</strong>, because these servers are responsible for your domain.</p>
<h3 id="heading-4-a-record-address-record-ipv4"><strong>4. A Record (Address Record IPv4)</strong></h3>
<p>⤷ <strong><em>Which IPv4 server does this domain point to ?</em></strong></p>
<p>The most common DNS record.</p>
<p>It maps a domain → IPv4 address.</p>
<p>Output from <code>nslookup prakashtsx.me</code> :</p>
<pre><code class="lang-plaintext">prakashtsx.me → A → 216.198.79.1
</code></pre>
<p>Meaning:</p>
<p>When someone types <a target="_blank" href="http://prakashtsx.me"><strong>prakashtsx.me</strong></a>, DNS tells the browser to go to <strong>216.198.79.1</strong>.</p>
<h3 id="heading-5-aaaa-record-ipv6-address-record"><strong>5. AAAA Record (IPv6 Address Record)</strong></h3>
<p>⤷ <strong><em>Which IPv6 server does this domain point to ?</em></strong></p>
<p>Same as A record, but for IPv6.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">prakashtsx.me → AAAA → 2606:4700::abcd
</code></pre>
<p>(Your domain may or may not have AAAA many small sites skip IPv6.)</p>
<p>♦ <strong><em>Some of you ask me what is IPv4 and IPv6 . So please refer to below i have write it properly which can help you to understand the main difference between both .</em></strong></p>
<h3 id="heading-ipv4-internet-protocol-version-4">✢ <strong>IPv4 (Internet Protocol Version 4)</strong></h3>
<p>⤑ <strong>This is the older and most common type of IP address.</strong></p>
<h3 id="heading-example">Example:</h3>
<pre><code class="lang-plaintext">216.198.79.1
</code></pre>
<h3 id="heading-structure"><strong>Structure</strong></h3>
<ul>
<li><p>4 numbers</p>
</li>
<li><p>Each between <strong>0–255</strong></p>
</li>
<li><p>Separated by dots</p>
</li>
<li><p>Total ≈ <strong>4.3 billion</strong> possible addresses</p>
</li>
</ul>
<h3 id="heading-why-ipv4-is-not-enough">✢ <strong>Why IPv4 is not enough?</strong></h3>
<p>⤑ The world ran out of IPv4 addresses because every device needs one:</p>
<ul>
<li><p>Phones</p>
</li>
<li><p>Laptops</p>
</li>
<li><p>Smart TVs</p>
</li>
<li><p>Servers</p>
</li>
<li><p>Cameras</p>
</li>
<li><p>IoT devices</p>
</li>
</ul>
<p>We needed a newer, bigger system.</p>
<hr />
<h3 id="heading-ipv6-internet-protocol-version-6">✢ <strong>IPv6 (Internet Protocol Version 6)</strong></h3>
<p>⤑ <strong><em>This is the newer version with almost unlimited addresses.</em></strong></p>
<h3 id="heading-example-1">Example:</h3>
<pre><code class="lang-plaintext">2606:4700:3033::ac43:bdff
</code></pre>
<h3 id="heading-structure-1"><strong>Structure</strong></h3>
<ul>
<li><p>Hexadecimal (0-9, a-f)</p>
</li>
<li><p>Separated by colons</p>
</li>
<li><p>Extremely large address space</p>
</li>
<li><p>Total = <strong>340 undecillion</strong> (3.4 × 10³⁸) addresses<br />  → Enough for every grain of sand on Earth to have millions of IPs</p>
</li>
</ul>
<h3 id="heading-why-ipv6-exists">✢ <strong>Why IPv6 exists?</strong></h3>
<p>To handle:</p>
<ul>
<li><p>Billions of new devices</p>
</li>
<li><p>Faster routing</p>
</li>
<li><p>More efficient networks</p>
</li>
<li><p>Better security (built-in features)</p>
</li>
</ul>
<hr />
<h3 id="heading-how-it-relates-to-dns">✢ <strong>How It Relates to DNS</strong></h3>
<p>DNS records are simply:</p>
<ul>
<li><p><strong>A Record</strong> → Domain → IPv4<br />  Example:<br />  <a target="_blank" href="http://prakashtsx.me"><code>prakashtsx.me</code></a> <code>→ 216.198.79.1</code></p>
</li>
<li><p><strong>AAAA Record</strong> → Domain → IPv6<br />  Example:<br />  <a target="_blank" href="http://example.com"><code>example.com</code></a> <code>→ 2606:4700:3033::1</code></p>
</li>
</ul>
<p>Both point your domain to a server just using two different formats.</p>
<h3 id="heading-6-cname-record-canonical-name-alias"><strong>6. CNAME Record (Canonical Name / Alias)</strong></h3>
<p><strong><em>This domain is actually another name.</em></strong></p>
<p>CNAME is used when :</p>
<p>⤑ One domain should point to <strong>another</strong> domain.</p>
<p>Output from <code>nslookup</code>:</p>
<pre><code class="lang-plaintext">blog.prakashtsx.me → CNAME → hashnode.network
hashnode.network → A → 76.76.21.21
</code></pre>
<p>Meaning :</p>
<ul>
<li><p>Your blog subdomain is an <strong>alias</strong></p>
</li>
<li><p>It points to <strong>Hashnode’s</strong> domain</p>
</li>
<li><p>Hashnode automatically provides the final IP</p>
</li>
</ul>
<p>CNAME is perfect for:</p>
<ul>
<li><p><a target="_blank" href="http://www.example.com"><code>www.example.com</code></a></p>
</li>
<li><p><a target="_blank" href="http://blog.example.com"><code>blog.example.com</code></a></p>
</li>
<li><p><a target="_blank" href="http://api.example.com"><code>api.example.com</code></a></p>
</li>
</ul>
<h3 id="heading-7-mx-record-mail-exchange-record"><strong>7. MX Record (Mail Exchange Record)</strong></h3>
<p><strong><em>Where should email for this domain be delivered ?</em></strong></p>
<p>If someone sends email to :</p>
<p><a target="_blank" href="mailto:someone@prakashtsx.me"><code>mail@prakashtsx.me</code></a></p>
<p>⤑ The sending email server checks the domain’s <strong>MX records</strong> to find the correct mail server.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">prakashtsx.me → MX → mailhost.someprovider.com
</code></pre>
<p>Without MX records, a domain <strong>cannot receive email</strong>.</p>
<h3 id="heading-8-txt-record-text-verification-security"><strong>8. TXT Record (Text / Verification / Security)</strong></h3>
<p>⤑ TXT records store <strong>extra information</strong>.</p>
<p>⤑ Originally created for notes, now heavily used for <strong>security</strong>.</p>
<p>Common uses:</p>
<h3 id="heading-spf-email-authentication">✢ <strong>SPF (Email authentication)</strong></h3>
<p>⤑ Specifies which servers are allowed to send mail for your domain.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">v=spf1 include:_spf.google.com ~all
</code></pre>
<h3 id="heading-dkim-email-signature-keys">✢ <strong>DKIM (Email signature keys)</strong></h3>
<h3 id="heading-dmarc-email-protection-rule">✢ <strong>DMARC (Email protection rule)</strong></h3>
<h3 id="heading-domain-verification"><strong>Domain Verification</strong></h3>
<ul>
<li><p>Google Search Console</p>
</li>
<li><p>Cloudflare</p>
</li>
<li><p>AWS</p>
</li>
<li><p>GitHub Pages</p>
</li>
<li><p>Hashnode</p>
</li>
<li><p>etc.</p>
</li>
</ul>
<p>Example:</p>
<pre><code class="lang-plaintext">google-site-verification=abc123xyz
</code></pre>
<p>⤑ TXT is extremely flexible and widely used.</p>
<h3 id="heading-9-simple-diagram-dns-flow">9. Simple Diagram: DNS Flow</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769015455561/07163f52-103b-46d7-9f25-a88039c748fd.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Networking Devices Explained]]></title><description><![CDATA[What is Network Devices ?
⤷ Network Devices are the physical things that are required for communication & interaction between computers on a computer network.
These devices can be physical, like routers or switches, or virtual, like cloud-based firew...]]></description><link>https://blog.prakashtsx.me/networking-devices</link><guid isPermaLink="true">https://blog.prakashtsx.me/networking-devices</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[networking]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Mon, 19 Jan 2026 17:03:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768842069220/900879c6-7339-45e3-881c-ec37ee8fb542.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-what-is-network-devices">What is Network Devices ?</h3>
<p>⤷ Network Devices are the physical things that are required for communication &amp; interaction between computers on a computer network.</p>
<p>These devices can be physical, like routers or switches, or virtual, like cloud-based firewalls and software-defined routers.</p>
<p>❊ Common Types Of Networks Devices Are :</p>
<ul>
<li><p>Routers</p>
</li>
<li><p>Switches</p>
</li>
<li><p>Hubs</p>
</li>
<li><p>Modems</p>
</li>
<li><p>Firewalls</p>
</li>
<li><p>Access points</p>
</li>
</ul>
<h3 id="heading-basic-overview-how-internet-reaches-to-our-home">❀ Basic Overview How Internet reaches to our home</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768833517582/da5b2ff9-57be-44af-850c-6b9153d13e9e.png" alt class="image--center mx-auto" /></p>
<p>This is the <em>basic flow</em> almost everywhere homes, offices, schools, startups.</p>
<p>Each device plays a very specific role.<br />If even one of them is missing, nothing works.</p>
<hr />
<h2 id="heading-explanation-of-different-network-devices">❀ Explanation of different Network Devices</h2>
<p>Now let’s go device by device and understand what they actually do.</p>
<ol>
<li><h3 id="heading-modem-the-gateway-from-isp-to-your-network"><mark>Modem : The Gateway From ISP to Your Network</mark></h3>
<p> ⤷ A <strong>modem</strong> is the first device that brings the internet into your home.<br /> Your Internet Service Provider (ISP) sends internet signals through fiber or cable in <strong>analog form</strong>, but your devices (phones, laptops, PCs) understand <strong>digital signals</strong>.</p>
<p> ⤑ <strong>MODem → MODulation + DEModulation</strong>.</p>
<ul>
<li><p><strong>Modulation:</strong> Converts your digital data into analog signals so it can travel through ISP cables.</p>
</li>
<li><p><strong>Demodulation:</strong> Converts incoming analog signals from your ISP back into digital form so your devices can understand them.</p>
</li>
</ul>
</li>
</ol>
<ol start="2">
<li><h3 id="heading-what-is-a-router-and-how-it-directs-traffic"><mark>What is a Router and How It Directs Traffic ?</mark></h3>
<p> ⤷ A <strong>router</strong> is the device that manages and directs all the internet traffic inside your home network.<br /> Once the modem brings internet into your house, the router takes that connection and distributes it to all your devices.</p>
</li>
</ol>
<p>⤑ What the router actually do ?</p>
<ul>
<li><p>Assigns <strong>IP addresses</strong> to every device</p>
</li>
<li><p>Decides <strong>which device gets which packet</strong></p>
</li>
<li><p>Sends traffic out to the internet</p>
</li>
<li><p>Receives incoming traffic and forwards it correctly</p>
</li>
<li><p>Creates <strong>Wi-Fi</strong> for wireless devices</p>
</li>
</ul>
<p>⤳ You know why this is called router : Because it routes (finds the path for) data packets between networks.</p>
<p>❊ In real world we can say A router is like traffic police officer at a busy junction : It looks at every packet and sends it to the right direction like laptop, phone, Tv, or out to the internet.</p>
<ol start="3">
<li><h3 id="heading-switch-vs-hub-how-local-networks-actually-works"><mark>Switch vs Hub : How local networks actually works ?</mark></h3>
<p> ⤷ Local networks (LANs) connect multiple devices inside your home or office.<br /> To understand how they communicate, you must know the difference between <strong>Hub</strong> and <strong>Switch</strong> because they look similar but work completely differently.</p>
</li>
</ol>
<h3 id="heading-what-is-hub">✢ What is Hub ?</h3>
<p>⤑ A hub sends every incoming packet to <strong>all</strong> connected devices—<br />whether they are the intended receiver or not.</p>
<h3 id="heading-problems-with-hub"><strong>Problems with Hub</strong></h3>
<ul>
<li><p>No security</p>
</li>
<li><p>Slow performance</p>
</li>
<li><p>Collisions</p>
</li>
<li><p>Wastes bandwidth</p>
</li>
</ul>
<h3 id="heading-analogy"><strong>Analogy</strong></h3>
<p>A hub is like <strong>shouting in a classroom</strong>.<br />Everyone hears everything even if the message is for one person.</p>
<h3 id="heading-what-is-switch">✢ <strong>What is Switch ?</strong></h3>
<p>A switch reads the <strong>MAC address</strong> and sends the packet <strong>only to the correct device</strong>.</p>
<h3 id="heading-benefits"><strong>Benefits</strong></h3>
<ul>
<li><p>Faster</p>
</li>
<li><p>Secure</p>
</li>
<li><p>No collisions</p>
</li>
<li><p>Efficient use of bandwidth</p>
</li>
</ul>
<h3 id="heading-analogy-1"><strong>Analogy</strong></h3>
<p>A switch is like <strong>whispering directly</strong> to the right person instead of shouting.</p>
<h3 id="heading-how-local-networks-actually-work">✢ <strong>How Local Networks Actually Work ?</strong></h3>
<p>Today, almost all homes and offices use <strong>switches</strong>, not hubs.</p>
<p>The router connects to a switch and the switch connects multiple wired devices:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768840358366/c2b0115a-c182-4e70-a592-1ef0e61082d0.png" alt /></p>
<p>This creates a fast, stable, collision-free local network.</p>
<ol start="4">
<li><h3 id="heading-what-is-a-firewall-and-why-security-lives-here"><mark>What is a Firewall and Why Security Lives Here ?</mark></h3>
<p> ⤷ A <strong>firewall</strong> is the security gate of your network.<br /> It decides what traffic is allowed to enter or leave and what should be blocked.</p>
</li>
</ol>
<h3 id="heading-what-a-firewall-actually-does">✢ <strong>What a Firewall Actually Does</strong></h3>
<ul>
<li><p>Checks every incoming and outgoing packet</p>
</li>
<li><p>Blocks dangerous or suspicious traffic</p>
</li>
<li><p>Allows only safe, approved connections</p>
</li>
<li><p>Protects devices from malware, attackers, and unauthorized access</p>
</li>
</ul>
<h3 id="heading-why-security-lives-here">✢ <strong>Why security “lives” here</strong></h3>
<p>⤑ Because the firewall is the <strong>first layer</strong> that faces the outside world.<br />It stands between the public internet and your private network,<br />so all security decisions happen at this point.</p>
<h3 id="heading-real-world-analogy"><strong>Real-World Analogy</strong></h3>
<p>A firewall is like the <strong>security guard at a building gate</strong>:</p>
<ul>
<li><p>Checks who you are</p>
</li>
<li><p>Decides if you can enter or not</p>
</li>
<li><p>Stops suspicious people</p>
</li>
<li><p>Allows safe visitors</p>
</li>
</ul>
<p>⤑ Sometimes the firewall is built inside the router.<br />In companies, it’s a separate dedicated device.</p>
<ol start="5">
<li><h3 id="heading-what-is-a-load-balancer-and-why-scalable-systems-need-it"><mark>What is a Load Balancer and Why Scalable Systems Need It ?</mark></h3>
<p> ⤷ A <strong>load balancer</strong> is a device (or software service) that distributes incoming traffic across multiple servers. Instead of sending all users to a single server, it spreads the load so the system stays fast, stable, and available.</p>
<h3 id="heading-what-a-load-balancer-actually-does">✢ <strong>What a Load Balancer Actually Does</strong></h3>
<ul>
<li><p>Distributes user requests across multiple servers</p>
</li>
<li><p>Prevents any single server from getting overloaded</p>
</li>
<li><p>Sends traffic to healthy servers only</p>
</li>
<li><p>Automatically reroutes if one server fails</p>
</li>
<li><p>Keeps applications fast even during peak traffic</p>
</li>
</ul>
</li>
</ol>
<h3 id="heading-why-scalable-systems-need-it">✢ <strong>Why scalable systems need it</strong></h3>
<p>    ⤑ When one server can't handle heavy traffic, the system becomes slow or crashes.<br />    A load balancer allows you to add multiple servers and scale horizontally.</p>
<p>    This is how big apps like Amazon, Instagram, Flipkart, and Netflix stay online even with millions of users.</p>
<h3 id="heading-real-world-analogy-1"><strong>Real-World Analogy</strong></h3>
<p>    ⤑ A load balancer is like a <strong>manager at a busy store</strong>:<br />    Customers come in → manager sends them to different counters<br />    so no single counter is overloaded.</p>
<ol start="6">
<li><h3 id="heading-how-all-these-devices-work-together-in-a-real-world-setup"><mark>How All These Devices Work Together in a Real-World Setup ?</mark></h3>
<p> ⤷ In a real home or office network, all these devices—modem, firewall, router, switch, and load balancer work together like parts of one system. Each device handles a specific step in the journey of your data.</p>
<p> ⤑ Below is the exact flow:</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768841314770/76f11f04-9374-4a58-bf74-9ca2977044a5.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Git for absolute beginners]]></title><description><![CDATA[If you've ever worked on a project and thought, "I wish I could go back to how this was yesterday," or accidentally deleted something important and panicked Git is here to save the day. Let me walk you through what Git is and why developers can't liv...]]></description><link>https://blog.prakashtsx.me/git-for-absolute-beginners</link><guid isPermaLink="true">https://blog.prakashtsx.me/git-for-absolute-beginners</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Tue, 13 Jan 2026 14:37:02 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768314735447/d31ea14c-1ef2-4a27-8c39-eb431184197a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you've ever worked on a project and thought, "I wish I could go back to how this was yesterday," or accidentally deleted something important and panicked <strong>Git</strong> is here to save the day. Let me walk you through what Git is and why developers can't live without it.</p>
<hr />
<h3 id="heading-what-is-git"><mark>What is Git ?</mark></h3>
<p>Think of Git as a time machine for your code. It's a <strong>distributed version control system</strong> that tracks every change you make to your files. Created by Linus Torvalds in 2005 (yes, the same person who created Linux), Git has become the backbone of modern software development.</p>
<p>But what does "distributed" actually mean? Unlike older systems where everything lived on one central server, Git gives every developer a complete copy of the project history on their own computer. You can work offline, experiment freely, and sync up with your team whenever you're ready.</p>
<h3 id="heading-why-git-is-used"><mark>Why Git is Used ?</mark></h3>
<h3 id="heading-1-never-lose-your-work">1. <strong>Never Lose Your Work</strong></h3>
<p>Git keeps a complete history of every change. Accidentally broke something? Just roll back to a working version. It's like having infinite "undo" for your entire project.</p>
<h3 id="heading-2-collaboration-made-simple">2. <strong>Collaboration Made Simple</strong></h3>
<p>Multiple people can work on the same project simultaneously without stepping on each other's toes. Git intelligently merges everyone's changes and helps resolve conflicts when they occur.</p>
<h3 id="heading-3-experimentation-without-fear">3. <strong>Experimentation Without Fear</strong></h3>
<p>Want to try a crazy new feature but worried it might break everything? Create a branch, experiment all you want, and if it doesn't work out, just delete it. Your main code stays safe.</p>
<h3 id="heading-4-professional-standard">4. <strong>Professional Standard</strong></h3>
<p>Whether you're applying for jobs or contributing to open source, Git knowledge is expected. GitHub, GitLab, and Bitbucket—all the major platforms are built around Git.</p>
<h3 id="heading-5-track-who-changed-what-and-why">5. <strong>Track Who Changed What and Why</strong></h3>
<p>Every change includes a message explaining what was done and who did it. This creates an invaluable audit trail for understanding how your project evolved.</p>
<h2 id="heading-git-basics-and-core-terminologies"><mark>Git Basics and Core Terminologies</mark></h2>
<p>Let's break down the essential concepts you need to understand:</p>
<h3 id="heading-repository-repo"><strong>Repository (Repo)</strong></h3>
<p>A repository is your project folder that Git is tracking. It contains all your files plus a hidden <code>.git</code> folder where Git stores its magic—the complete history of every change.</p>
<h3 id="heading-working-directory"><strong>Working Directory</strong></h3>
<p>This is your normal project folder where you edit files. It's what you see in your file explorer or code editor.</p>
<h3 id="heading-staging-area-index"><strong>Staging Area (Index)</strong></h3>
<p>Think of this as a preparation zone. Before Git permanently saves your changes, you add them to the staging area. This lets you carefully choose exactly what to include in your next save point.</p>
<h3 id="heading-commit"><strong>Commit</strong></h3>
<p>A commit is a snapshot of your project at a specific moment in time. Each commit has a unique ID and includes a message describing what changed. It's like taking a photograph of your code that you can return to later.</p>
<h3 id="heading-branch"><strong>Branch</strong></h3>
<p>A branch is an independent line of development. The default branch is usually called <code>main</code> or <code>master</code>. When you create a new branch, you're creating a parallel universe where you can make changes without affecting the main timeline.</p>
<h3 id="heading-head"><strong>HEAD</strong></h3>
<p>HEAD is simply a pointer showing you which commit you're currently looking at—usually the latest commit on your current branch.</p>
<h3 id="heading-remote"><strong>Remote</strong></h3>
<p>A remote is a version of your repository hosted somewhere else, typically on GitHub or GitLab. It's how you share your work and collaborate with others.</p>
<h3 id="heading-clone"><strong>Clone</strong></h3>
<p>Cloning creates a complete copy of a remote repository on your local machine, including all its history.</p>
<h3 id="heading-merge"><strong>Merge</strong></h3>
<p>Merging combines changes from different branches. When you finish a feature on a separate branch, you merge it back into your main branch.</p>
<h2 id="heading-common-git-commands">Common Git Commands</h2>
<p>Here are the commands you'll use constantly, explained with real-world context:</p>
<h3 id="heading-setting-up-git"><strong>Setting Up Git</strong></h3>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Tell Git who you are (do this once)</span>
git config --global user.name <span class="hljs-string">"Your Name"</span>
git config --global user.email <span class="hljs-string">"your.email@example.com"</span>

<span class="hljs-comment"># Start tracking a new project</span>
git init

<span class="hljs-comment"># Copy an existing project from GitHub/GitLab</span>
git <span class="hljs-built_in">clone</span> https://github.com/username/project.git
</code></pre>
<h3 id="heading-daily-workflow-commands"><strong>Daily Workflow Commands</strong></h3>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Check what's changed</span>
git status

<span class="hljs-comment"># Add specific files to staging</span>
git add filename.txt

<span class="hljs-comment"># Add all changed files to staging</span>
git add .

<span class="hljs-comment"># Save your staged changes permanently</span>
git commit -m <span class="hljs-string">"Add user login feature"</span>

<span class="hljs-comment"># See your commit history</span>
git <span class="hljs-built_in">log</span>

<span class="hljs-comment"># See a simplified commit history</span>
git <span class="hljs-built_in">log</span> --oneline
</code></pre>
<h3 id="heading-working-with-branches"><strong>Working with Branches</strong></h3>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Create a new branch</span>
git branch feature-name

<span class="hljs-comment"># Switch to a branch</span>
git checkout feature-name

<span class="hljs-comment"># Create and switch to a new branch in one command</span>
git checkout -b feature-name

<span class="hljs-comment"># List all branches</span>
git branch

<span class="hljs-comment"># Merge another branch into your current branch</span>
git merge feature-name

<span class="hljs-comment"># Delete a branch you no longer need</span>
git branch -d feature-name
</code></pre>
<h3 id="heading-collaborating-with-others"><strong>Collaborating with Others</strong></h3>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Upload your commits to GitHub/GitLab</span>
git push origin main

<span class="hljs-comment"># Download new changes from GitHub/GitLab</span>
git pull origin main

<span class="hljs-comment"># See all remote connections</span>
git remote -v
</code></pre>
<h3 id="heading-fixing-mistakes"><strong>Fixing Mistakes</strong></h3>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Undo changes in a file (before staging)</span>
git checkout -- filename.txt

<span class="hljs-comment"># Remove a file from staging (but keep your changes)</span>
git reset filename.txt

<span class="hljs-comment"># Go back to a previous commit (careful with this!)</span>
git reset --hard commit-id

<span class="hljs-comment"># Create a new commit that undoes a previous commit</span>
git revert commit-id
</code></pre>
<h3 id="heading-useful-information-commands"><strong>Useful Information Commands</strong></h3>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># See what changed in your files</span>
git diff

<span class="hljs-comment"># See what changed in staged files</span>
git diff --staged

<span class="hljs-comment"># Show details about a specific commit</span>
git show commit-id
</code></pre>
<h2 id="heading-a-basic-developer-workflow">A Basic Developer Workflow</h2>
<p>Let me show you how a typical day of coding with Git looks:</p>
<p><strong>Morning: Starting a New Feature</strong></p>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Make sure you have the latest code</span>
git pull origin main

<span class="hljs-comment"># Create a new branch for your work</span>
git checkout -b add-dark-mode

<span class="hljs-comment"># Make your changes in your editor...</span>
</code></pre>
<p><strong>Afternoon: Saving Your Progress</strong></p>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Check what you've changed</span>
git status

<span class="hljs-comment"># Stage your changes</span>
git add styles.css
git add theme-switcher.js

<span class="hljs-comment"># Commit with a descriptive message</span>
git commit -m <span class="hljs-string">"Implement dark mode toggle with user preference saving"</span>
</code></pre>
<p><strong>End of Day: Sharing Your Work</strong></p>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Push your branch to the remote repository</span>
git push origin add-dark-mode

<span class="hljs-comment"># Open a pull request on GitHub/GitLab for review</span>
</code></pre>
<p><strong>Next Day: After Approval</strong></p>
<p>bash</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Switch back to main branch</span>
git checkout main

<span class="hljs-comment"># Get the latest changes (including your merged feature)</span>
git pull origin main

<span class="hljs-comment"># Delete your old feature branch</span>
git branch -d add-dark-mode
</code></pre>
<h2 id="heading-visual-understanding">Visual Understanding</h2>
<h3 id="heading-the-three-states-of-git">The Three States of Git</h3>
<p><img src="https://miro.medium.com/v2/1*pqTFygLG8DC79fj6sal7cA.png" alt="The Three States of Git" /></p>
<p>When you modify a file, it's in your working directory. Using <code>git add</code> moves it to the staging area. Finally, <code>git commit</code> permanently saves it to your repository.</p>
<h3 id="heading-repository-structure">Repository Structure</h3>
<pre><code class="lang-plaintext">my-project/
├── .git/                    (Git's database - don't touch!)
│   ├── objects/             (All your commits and files)
│   ├── refs/                (Branch pointers)
│   └── HEAD                 (Current branch pointer)
├── src/
│   └── main.js
├── README.md
└── .gitignore               (Files to ignore)
</code></pre>
<h3 id="heading-commit-history-flow">Commit History Flow</h3>
<pre><code class="lang-plaintext">main branch:  A ← B ← C ← D ← E (HEAD)
                    ↖
feature branch:      F ← G
</code></pre>
<p>Each letter represents a commit. The main branch has commits A through E. A feature branch split off at commit B and has its own commits F and G.</p>
<hr />
<p>Git feels overwhelming at first I won't lie to you. But here's the secret: you don't need to memorize everything. Start with the basics: <code>init</code>, <code>add</code>, <code>commit</code>, <code>push</code>, and <code>pull</code>. These five commands will cover 80% of your daily work.</p>
]]></content:encoded></item><item><title><![CDATA[Inside Git: How It Works and the Role of the .git Folder]]></title><description><![CDATA[Introduction
Let me be honest when I first started using Git, I was just blindly following commands:
git init  
git add .  
git commit -m "First commit"

In this blog, I’ll break down what happens under the hood how Git stores your files, what lives ...]]></description><link>https://blog.prakashtsx.me/inside-git-folder</link><guid isPermaLink="true">https://blog.prakashtsx.me/inside-git-folder</guid><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Wed, 31 Dec 2025 17:19:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1767201466606/8a5b8048-1372-4567-a3f6-188ee58117fb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Let me be honest when I first started using Git, I was just blindly following commands:</p>
<pre><code class="lang-bash">git init  
git add .  
git commit -m <span class="hljs-string">"First commit"</span>
</code></pre>
<p>In this blog, I’ll break down what happens under the hood how Git stores your files, what lives inside the <code>.git</code> folder, and how Git tracks your changes using blobs, trees, and commits.</p>
<hr />
<h2 id="heading-what-is-the-git-folder">📁 What is the <code>.git</code> Folder?</h2>
<p>The <code>.git</code> folder is created the moment you run:</p>
<pre><code class="lang-bash">git init
</code></pre>
<p>This hidden directory is where <strong>Git stores all version control data</strong>. Think of it as the <strong>brain of Git</strong>.</p>
<p>Without this folder, Git has no memory of your commits, branches, or file history.</p>
<hr />
<h2 id="heading-git-folder-structure"><code>.git</code> Folder Structure</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767198958660/ead76461-cedc-40d4-9b10-5ad16016f182.webp" alt=".git folder" class="image--center mx-auto" /></p>
<p><strong>Key Parts</strong>:</p>
<ul>
<li><p><code>HEAD</code>: Points to your current branch</p>
</li>
<li><p><code>objects/</code>: Contains all actual content, hashed and compressed</p>
</li>
<li><p><code>refs/heads/</code>: Contains your branch references</p>
</li>
</ul>
<hr />
<h2 id="heading-git-objects-blob-tree-and-commit">Git Objects: Blob, Tree, and Commit</h2>
<p>Git stores data as objects. There are 3 main types:</p>
<h3 id="heading-1-blob-binary-large-object">1. <strong>Blob (Binary Large Object)</strong></h3>
<ul>
<li><p>Stores the <strong>content</strong> of a file.</p>
</li>
<li><p>Doesn’t care about filename, just the content.</p>
</li>
</ul>
<p><strong>Example</strong>:<br />If you write <code>Hello World</code> in <code>file.txt</code>, Git saves that content as a blob and gives it a unique hash.</p>
<hr />
<h3 id="heading-2-tree">2. <strong>Tree</strong></h3>
<ul>
<li><p>Represents <strong>folders or directory structures</strong>.</p>
</li>
<li><p>Stores filenames and links them to blob hashes.</p>
</li>
</ul>
<p><strong>Example</strong>:<br />A tree might say:</p>
<ul>
<li><p><code>file.txt</code> → points to blob <code>abc123</code></p>
</li>
<li><p><code>about/</code> → points to another tree</p>
</li>
</ul>
<hr />
<h3 id="heading-3-commit">3. <strong>Commit</strong></h3>
<ul>
<li><p>A <strong>snapshot</strong> of the entire project at a specific point in time.</p>
</li>
<li><p>Stores:</p>
<ul>
<li><p>A pointer to the tree</p>
</li>
<li><p>A commit message</p>
</li>
<li><p>Author info</p>
</li>
<li><p>A pointer to the <strong>previous commit</strong></p>
</li>
</ul>
</li>
</ul>
<hr />
<h2 id="heading-commit-tree-blob-structure">Commit → Tree → Blob Structure</h2>
<p>Visualize this like a linked chain:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767198732320/d4bb396c-7f0e-4c59-9840-51dd0262896a.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-how-git-tracks-changes">How Git Tracks Changes</h2>
<p>Unlike some version control systems that store <em>diffs</em>, Git stores <strong>complete snapshots</strong>.</p>
<p>When you commit, Git doesn’t say “this line changed” - it says:</p>
<blockquote>
<p>“Here’s the full state of the project right now, and here’s what changed compared to the previous commit.”</p>
</blockquote>
<p>This is made possible by the <strong>content-addressed</strong> system using <strong>SHA-1 hashes</strong>.</p>
<hr />
<h2 id="heading-what-happens-when-you-run-git-add">What Happens When You Run <code>git add</code>?</h2>
<p>Let’s say you run:</p>
<pre><code class="lang-bash">git add index.html
</code></pre>
<p>Here’s what Git does internally:</p>
<ol>
<li><p>Takes the <strong>content</strong> of <code>index.html</code></p>
</li>
<li><p>Creates a <strong>blob object</strong> for it</p>
</li>
<li><p>Adds an entry to the <strong>staging area</strong> (aka <strong>index</strong>) to mark it for commit</p>
</li>
</ol>
<p><strong>Note</strong>: Git doesn’t care about file names at this point only content!</p>
<hr />
<h2 id="heading-what-happens-when-you-run-git-commit">What Happens When You Run <code>git commit</code>?</h2>
<p>Let’s say you run:</p>
<pre><code class="lang-bash">git commit -m <span class="hljs-string">"Add homepage"</span>
</code></pre>
<p>Git performs 3 actions:</p>
<ol>
<li><p>Takes the files in the <strong>staging area</strong></p>
</li>
<li><p>Creates a <strong>tree object</strong></p>
</li>
<li><p>Creates a <strong>commit object</strong>, linking to:</p>
<ul>
<li><p>the tree</p>
</li>
<li><p>the previous commit</p>
</li>
<li><p>the message and author</p>
</li>
</ul>
</li>
<li><p>Updates the branch (like <code>main</code>) to point to this new commit</p>
</li>
</ol>
<hr />
<h2 id="heading-git-workflow-add-commit">Git Workflow (Add → Commit)</h2>
<p>Here’s how the process flows:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767198687465/56f34d7f-428d-4b00-921f-c3eae52420f7.png" alt="git workflow" class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-git-hashes-the-backbone-of-git">Git Hashes: The Backbone of Git</h2>
<p>Everything Git stores is hashed using SHA-1.</p>
<p>For example, this:</p>
<pre><code class="lang-bash">git hash-object index.html
</code></pre>
<p>…might return:</p>
<pre><code class="lang-plaintext">e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
</code></pre>
<p>This means Git is saving content by its hash not file name.</p>
<p>Why is this awesome?</p>
<ul>
<li><p>Ensures <strong>data integrity</strong></p>
</li>
<li><p>Detects even the tiniest changes</p>
</li>
<li><p>Prevents duplication</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Why Version Control Exists and Why Developers Need It ?]]></title><description><![CDATA[A real-life example to understand Git and version control

Description
Before version control systems existed, developers had no proper way to manage code changes.They shared projects using pendrives, emails, and local folders, which worked only for ...]]></description><link>https://blog.prakashtsx.me/why-version-control-exists</link><guid isPermaLink="true">https://blog.prakashtsx.me/why-version-control-exists</guid><category><![CDATA[Git]]></category><category><![CDATA[version control]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Prakash]]></dc:creator><pubDate>Tue, 30 Dec 2025 17:31:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1767115570905/33c288b2-5a24-45db-96ec-489aa5a9bed2.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p><strong>A real-life example to understand Git and version control</strong></p>
</blockquote>
<h2 id="heading-description">Description</h2>
<p>Before version control systems existed, developers had no proper way to manage code changes.<br />They shared projects using <strong>pendrives, emails, and local folders</strong>, which worked only for very small tasks.</p>
<p>As projects and teams grew, this approach started failing badly.<br />This blog explains <strong>why version control exists</strong>, using a simple real-life analogy and then connects it to how modern <strong>Version Control Systems (VCS)</strong> work today.</p>
<hr />
<h2 id="heading-life-before-version-control-system">Life Before Version Control System :</h2>
<p><img src="https://elie.net//_astro/what-are-malicious-usb-keys-and-how-to-create-a-realistic-one.Bul9ePMs_ZhAYqk.jpg" alt="Pendrive Image" /></p>
<p>Before version control systems existed, developers managed code <strong>manually</strong>.</p>
<p>A developer would write code on their computer and share it with others using:</p>
<ul>
<li><p>Pendrives</p>
</li>
<li><p>Email attachments</p>
</li>
<li><p>ZIP files</p>
</li>
</ul>
<p>After getting feedback, the code was changed and shared again in the same way.</p>
<p>At first, this looked simple.<br />But when changes increased, problems started.</p>
<p>To avoid losing work, developers created folders like:</p>
<ul>
<li><p>final</p>
</li>
<li><p>final_v2</p>
</li>
<li><p>latest_final</p>
</li>
</ul>
<p>Soon, even the developer could not answer:</p>
<ul>
<li><p>Which version is the latest?</p>
</li>
<li><p>What changed last time?</p>
</li>
<li><p>Who made those changes?</p>
</li>
</ul>
<p>When multiple people worked on the same code:</p>
<ul>
<li><p>Files overwrote each other</p>
</li>
<li><p>Changes were lost</p>
</li>
<li><p>There was no history of edits</p>
</li>
</ul>
<p>Pendrives also had risks:</p>
<ul>
<li><p>They could be lost</p>
</li>
<li><p>They could get corrupted</p>
</li>
<li><p>They worked only for one person at a time</p>
</li>
</ul>
<p>This made collaboration slow, confusing, and unsafe.</p>
<p>This entire situation is known as the <strong>Pendrive Problem</strong>.<br />It clearly showed that <strong>manual code sharing does not work</strong>, especially for teams.</p>
<p>This is why developers needed a better solution - <strong>Version Control Systems</strong>.</p>
<hr />
<h2 id="heading-introduction-to-version-control-systems"><mark>Introduction to Version Control Systems :</mark></h2>
<p><img src="https://i0.wp.com/blog.nashtechglobal.com/wp-content/uploads/2024/01/1_r46_PENruSre5iTHcwGPTQ.png?fit=700%2C350&amp;ssl=1" alt="Version Control System" /></p>
<p>A <strong>Version Control System (VCS)</strong> is a tool that helps developers <strong>track and manage changes</strong> to code.</p>
<p>A VCS allows developers to:</p>
<ul>
<li><p>Record every update to the codebase</p>
</li>
<li><p>Collaborate without overwriting each other’s work</p>
</li>
<li><p>Go back to earlier versions if needed</p>
</li>
<li><p>Maintain a clear history of changes</p>
</li>
</ul>
<p>Instead of pendrives, developers work using a <strong>repository</strong>.</p>
<hr />
<h2 id="heading-how-version-control-works-simple-view">How Version Control Works (Simple View) :</h2>
<p><img src="https://miro.medium.com/v2/resize%3Afit%3A1400/1%2AGgaGcwh5L246YcU5NVDA5A.png" alt="Centralized vs Distributed Version Control Systems | by Mateusz ..." /></p>
<p>Instead of sharing code using pendrives or WhatsApp, developers use a <strong>repository</strong> to work together.</p>
<ul>
<li><p>The <strong>repository</strong> is a central place where the main project code is stored.</p>
</li>
<li><p>Every developer has their own <strong>working copy</strong> on their computer.</p>
</li>
<li><p>Developers make changes in their working copy without affecting others.</p>
</li>
<li><p>When a change is ready, they <strong>commit</strong> it to the repository.</p>
</li>
<li><p>Other developers <strong>update</strong> their working copy to get the latest changes.</p>
</li>
<li><p>This way, everyone stays in sync and works on the same project safely.</p>
</li>
</ul>
<p>In short :<br />\&gt; <strong>Repository = main storage</strong><br />\&gt; <strong>Working copy = personal workspace</strong><br />\&gt; <strong>Commit = send changes</strong><br />\&gt; <strong>Update = receive changes</strong></p>
<p>This system makes teamwork organized, safe, and efficient.</p>
<hr />
<h2 id="heading-why-version-control-became-mandatory-in-modern-development">Why Version Control Became Mandatory in Modern Development</h2>
<p>As software projects became bigger and more complex, developers needed a better solution.</p>
<p>Version Control Systems were created to:</p>
<ul>
<li><p>Track every change made to the code</p>
</li>
<li><p>Prevent data loss</p>
</li>
<li><p>Maintain complete history</p>
</li>
<li><p>Allow multiple developers to work together safely</p>
</li>
</ul>
<p>Instead of sharing files manually, developers started working on a <strong>shared repository</strong>.</p>
<p>This made collaboration faster, safer, and more reliable.</p>
<p>Today, version control is not optional.<br />It is a <strong>mandatory part of modern software development</strong>.</p>
<hr />
<h2 id="heading-popular-version-control-systems">Popular Version Control Systems :</h2>
<p><img src="https://media.geeksforgeeks.org/wp-content/uploads/20250725150911102724/top_5_free_version_control_system.webp" alt="version controls system" /></p>
<p>Git is the most widely used Distributed Version Control System, developed by <strong>Linus Torvalds in 2005</strong> for managing the Linux kernel. It is highly efficient, supports branching and merging, and has a fast, decentralized workflow. <strong>Git is the backbone of services</strong> like GitHub, GitLab and Bitbucket, making it a popular choice for developers worldwide.</p>
]]></content:encoded></item></channel></rss>