<?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[mukul2244]]></title><description><![CDATA[mukul2244]]></description><link>https://blogs.mukuldev.in</link><generator>RSS for Node</generator><lastBuildDate>Wed, 27 May 2026 15:42:27 GMT</lastBuildDate><atom:link href="https://blogs.mukuldev.in/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How React Virtual DOM works under the Hood]]></title><description><![CDATA[React never touches the Real DOM directly on every state change. Instead, it builds a lightweight JavaScript copy of the DOM (Virtual DOM), compares the new version against the old one (diffing/reconc]]></description><link>https://blogs.mukuldev.in/how-react-virtual-dom-works-under-the-hood</link><guid isPermaLink="true">https://blogs.mukuldev.in/how-react-virtual-dom-works-under-the-hood</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[React]]></category><category><![CDATA[virtual dom]]></category><category><![CDATA[WebDevCohort2026]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 09 May 2026 05:22:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/7bbf12ea-514f-4994-98cc-cb3b13a7ef66.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>React never touches the Real DOM directly on every state change. Instead, it builds a lightweight JavaScript copy of the DOM (Virtual DOM), compares the new version against the old one (diffing/reconciliation), and applies only the minimal set of changes to the Real DOM. This post explains exactly how that process works.</p>
<h3>Problem : Slow direct DOM manipulation</h3>
<p>Before React, developers manipulated the browser's DOM directly — using <code>document.getElementById</code>, <code>innerHTML</code>, and similar APIs. This works fine for simple pages, but falls apart at scale.</p>
<p>Here is why : every time you touch the real DOM, the browser has to do a lot of work behind the scenes.</p>
<ul>
<li><p><strong>Reflow</strong> — recalculates the layout of all affected elements</p>
</li>
<li><p><strong>Repaint</strong> — redraws the pixels on screen</p>
</li>
<li><p><strong>Layout thrashing</strong> — if you read and write the DOM repeatedly in a loop, the browser recalculates layout every single time</p>
</li>
</ul>
<p>Imagine a dynamic dashboard that updates 50 data points every second. Touching the DOM 50 times per second, even for minor changes, causes visible jank and sluggishness — because you are repeatedly forcing the browser through that expensive cycle.</p>
<p>The core problem is not that the DOM is badly designed. It is that <strong>updating the DOM frequently, even for small changes, is expensive</strong>. Developers needed a smarter way to batch updates and avoid unnecessary work.</p>
<h3>Real DOM vs Virtual DOM</h3>
<p>Understanding the Virtual DOM starts with appreciating what the real DOM actually is.</p>
<h3>The Real DOM</h3>
<p>The <strong>Document Object Model (DOM)</strong> is the browser's live, structured representation of your HTML. It is a tree of nodes — every element, attribute, and piece of text is a node. The browser keeps this tree in sync with what you see on screen, which is why modifying it triggers reflows and repaints.</p>
<p>The real DOM is powerful, but it is <strong>slow to update repeatedly</strong> because each modification can cascade through the layout engine.</p>
<h3>The Virtual DOM</h3>
<p>The <strong>Virtual DOM</strong> is a plain JavaScript object tree that mirrors the structure of the real DOM — but it lives entirely in memory and has no connection to the browser's rendering engine.</p>
<p>js</p>
<pre><code class="language-js">// A simplified Virtual DOM node looks like this:
{
  type: 'button',
  props: {
    className: 'btn btn-primary',
    onClick: handleClick
  },
  children: [
    { type: 'TEXT', value: 'Submit' }
  ]
}
</code></pre>
<p>Because it is just a JavaScript object, creating and discarding it is essentially free compared to touching the real DOM. JavaScript engines are highly optimized for object manipulation — it is several orders of magnitude faster than layout and paint operations.</p>
<table>
<thead>
<tr>
<th>Aspect</th>
<th>Real DOM</th>
<th>Virtual DOM</th>
</tr>
</thead>
<tbody><tr>
<td>Lives in</td>
<td>Browser memory (C++)</td>
<td>JavaScript memory (V8/SpiderMonkey)</td>
</tr>
<tr>
<td>Updating cost</td>
<td>High (reflow + repaint)</td>
<td>Near zero (object creation)</td>
</tr>
<tr>
<td>Directly renders</td>
<td>Yes</td>
<td>No — synced to real DOM selectively</td>
</tr>
<tr>
<td>Manipulation speed</td>
<td>Slow for frequent changes</td>
<td>Very fast</td>
</tr>
</tbody></table>
<h3>The Initial Render: Component → Virtual DOM → Real DOM</h3>
<p>When your React application first loads, it follows a clear three-step process.</p>
<h3>Step 1 — JSX compiles to React elements</h3>
<p>You write JSX, which looks like HTML inside JavaScript:</p>
<p>jsx</p>
<pre><code class="language-javascript">function App() {
  return (
    &lt;div className="app"&gt;
      &lt;Header title="My App" /&gt;
      &lt;List items={data} /&gt;
    &lt;/div&gt;
  );
}
</code></pre>
<p>Babel compiles this into nested <code>React.createElement()</code> calls:</p>
<p>js</p>
<pre><code class="language-js">React.createElement('div', { className: 'app' },
  React.createElement(Header, { title: 'My App' }),
  React.createElement(List, { items: data })
)
</code></pre>
<p>Each <code>createElement</code> call returns a plain object — a <strong>React element</strong> — which is the building block of the Virtual DOM tree.</p>
<h3>Step 2 — The Virtual DOM tree is assembled</h3>
<p>React calls your component functions top-down, collecting every React element produced. The result is a complete Virtual DOM tree representing the entire UI.</p>
<pre><code class="language-plaintext">App (div.app)
├── Header (h1)
│   └── "My App"
└── List (ul)
    ├── Item (li) → "Item 1"
    └── Item (li) → "Item 2"
</code></pre>
<h3>Step 3 — The real DOM is built from scratch</h3>
<p>Since there is no previous tree to compare against, React takes the Virtual DOM and creates actual DOM nodes — <code>document.createElement</code>, <code>appendChild</code>, <code>setAttribute</code> — for every node in the tree. This initial paint touches the DOM fully, but it only happens once.</p>
<h2>How State or Props Changes Trigger a Re-render</h2>
<p>Once the app is running, updates come from two sources: <strong>state changes</strong> and <strong>prop changes</strong>.</p>
<p>When you call a state setter from <code>useState</code> (in a function component), React marks that component as dirty and schedules a re-render. Similarly, if a parent component re-renders and passes different props down, the child is also re-rendered.</p>
<p>jsx</p>
<pre><code class="language-jsx">function Counter() {
  const [count, setCount] = useState(0);

  return (
    &lt;div&gt;
      &lt;p&gt;Count: {count}&lt;/p&gt;
      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;/button&gt;
    &lt;/div&gt;
  );
}
</code></pre>
<p>When the button is clicked, <code>setCount</code> is called. React does <strong>not</strong> immediately update the DOM. Instead, it schedules a re-render, which kicks off the next two phases: creating a new Virtual DOM tree, and diffing it against the old one.</p>
<h2>Creating a New Virtual DOM Tree</h2>
<p>When a re-render is triggered, React calls the component function again. It executes the function from the top, with the new state values, and produces a brand-new Virtual DOM tree.</p>
<pre><code class="language-plaintext">New Virtual DOM (after count = 1):

Counter (div)
├── p → "Count: 1"    ← changed
└── button → "Increment"
</code></pre>
<p>This new tree is held in memory alongside the previous (current) tree. React now has two snapshots of the UI — one representing what is currently on screen, and one representing what should be on screen. The job of the next phase is to find the difference between them.</p>
<h2>Reconciliation: Comparing Two Trees</h2>
<p><strong>Reconciliation</strong> is the process of comparing the old Virtual DOM tree against the new one to determine what, if anything, has changed in the real DOM.</p>
<p>Think of it like a diff tool for code — except instead of comparing lines of text, React compares tree nodes. The goal is to answer one question: <strong>what is the minimum set of real DOM mutations needed to bring the screen in sync with the new state?</strong></p>
<p>Without smart heuristics, tree diffing is an O(n³) problem — comparing every node against every other node is prohibitively expensive for large UIs. React solves this with two key heuristics that make it O(n).</p>
<h3>The Full React Lifecycle: Render → Diff → Commit</h3>
<p>Here’s the complete React update lifecycle in simple terms:</p>
<ol>
<li><p>User interacts with UI</p>
</li>
<li><p>State or props change</p>
</li>
<li><p>React creates a new Virtual DOM tree</p>
</li>
<li><p>React compares old vs new tree</p>
</li>
<li><p>Differences are identified</p>
</li>
<li><p>Minimal updates are applied</p>
</li>
<li><p>Real DOM updates</p>
</li>
<li><p>Browser then repaints the respective changed parts</p>
</li>
</ol>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/bc9a8652-9773-43ee-8604-3333485b7f0b.png" alt="" style="display:block;margin:0 auto" />

<h3>Conclusion</h3>
<p>React’s Virtual DOM is one of the key ideas that makes modern React applications efficient and scalable.</p>
<p>Instead of blindly updating the entire page, React intelligently:</p>
<ul>
<li><p>creates Virtual DOM trees</p>
</li>
<li><p>compares changes</p>
</li>
<li><p>updates only necessary elements</p>
</li>
</ul>
<p>This approach allows developers to build highly interactive applications while maintaining good performance. Understanding this mental model makes React’s rendering behavior much easier to reason about and debug.</p>
<h2>Key Takeaways</h2>
<ul>
<li><p>The <strong>real DOM</strong> is expensive to update frequently because every change can trigger reflow and repaint.</p>
</li>
<li><p>The <strong>Virtual DOM</strong> is a plain JavaScript object tree — cheap to create, discard, and compare.</p>
</li>
<li><p>On <strong>initial render</strong>, React builds the Virtual DOM top-down and writes every node to the real DOM.</p>
</li>
<li><p>On <strong>re-render</strong>, React produces a new Virtual DOM tree and keeps the old one for comparison.</p>
</li>
<li><p>The <strong>reconciler</strong> diffs both trees using O(n) heuristics: different type → rebuild; same type → patch; lists → use keys.</p>
</li>
<li><p>The <strong>commit phase</strong> flushes only the minimal changes to the real DOM in a single synchronous pass.</p>
</li>
<li><p>This model makes React fast by doing all the heavy thinking in JavaScript and touching the DOM as little as possible.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Setting Up Your First Node.js Application ]]></title><description><![CDATA[Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to execute JavaScript code outside of a web browser, primarily for building server-side and network appl]]></description><link>https://blogs.mukuldev.in/setting-up-your-first-node-js-application</link><guid isPermaLink="true">https://blogs.mukuldev.in/setting-up-your-first-node-js-application</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[chaicode webdev cohort 2026]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Tue, 28 Apr 2026 20:42:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/e1c550f9-f62f-4915-b3c1-cff82f20fed1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Node.js</strong> is an <strong>open-source, cross-platform JavaScript runtime environment</strong> that allows developers to execute JavaScript code outside of a web browser, primarily for building server-side and network applications. Built on Google’s <strong>V8 JavaScript engine</strong>, it enables the use of a single programming language for both frontend and backend development, streamlining workflows and reducing context switching.</p>
<h3>Installing Node.js</h3>
<p>To setup our first node.js application, we need to download the node.js from the official docs of node.js.</p>
<p>You can visit to this download link <a href="https://nodejs.org/en/download">https://nodejs.org/en/download</a></p>
<h3>Checking installation using terminal</h3>
<p>Once node.js is installed on the local system , try running these commands.</p>
<pre><code class="language-javascript">node -v // show the nodejs version, eg. - v22.13.1
npm -v // show the npm version, eg. - 11.5.2

// npm is the package manager for the node.js. 
</code></pre>
<h3>Understanding Node REPL</h3>
<p>Before writing files, let’s understand something powerful:</p>
<p><code>REPL(Read Eval Print Loop)</code></p>
<p>Just open the terminal and run <code>node</code> command. With this environment we can run the JS directly in the terminal.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/23d80f35-8da3-4400-a88f-d56b44f6ab31.png" alt="" style="display:block;margin:0 auto" />

<p>For Example -</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/f680b602-df51-4d58-8203-50e6ff90f3db.png" alt="" style="display:block;margin:0 auto" />

<h3>Creating first JS file</h3>
<p>Create the file with any name and with .<code>js</code> extension.</p>
<p>To create the file directly from the terminal, you can use <code>touch</code> utility.</p>
<pre><code class="language-shell">touch app.js 
</code></pre>
<p>This <code>touch</code> utility will only works with unix based system. This utility does not works in the windows.</p>
<p>Add this code in the file :</p>
<pre><code class="language-javascript">console.log("Hello World");
</code></pre>
<h3>Running script using node command</h3>
<p>To run the created file we can use this command</p>
<pre><code class="language-javascript">node &lt;file_name&gt;.js
</code></pre>
<p>replace the <code>&lt;file_name&gt;</code> with your actual file name.</p>
<h3>Writing Hello World server</h3>
<p>Now just replace the code inside <code>app.js</code> with this -</p>
<pre><code class="language-javascript">// app.js
import { createServer } from 'node:http';

const server = createServer((req, res) =&gt; {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello World!\n');
});

// starts a simple http server locally on port 3000
server.listen(3000, () =&gt; {
  console.log('Server running on http://localhost:3000');
});
</code></pre>
<p>Now run <code>node app.js</code> command.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/36a63771-72c5-468a-a1d0-6478db113846.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/a5b4c502-5c46-433f-a35a-e633f53f4a27.png" alt="" style="display:block;margin:0 auto" />

<p>You just created your first backend server. That all for this article, if you like these articles do follow me on X and github.</p>
]]></content:encoded></item><item><title><![CDATA[The new Keyword in JavaScript]]></title><description><![CDATA[The new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function.
What Does the new Keyword Actually Do?
When a ]]></description><link>https://blogs.mukuldev.in/the-new-keyword-in-javascript</link><guid isPermaLink="true">https://blogs.mukuldev.in/the-new-keyword-in-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[chaicode webdev cohort 2026]]></category><category><![CDATA[JavaScript new keyword,]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Tue, 28 Apr 2026 19:41:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/8128a69e-9d54-41ba-bdcd-42aab6b775b7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The <code>new</code> operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function.</p>
<h2><strong>What Does the</strong> <code>new</code> <strong>Keyword Actually Do?</strong></h2>
<p>When a function is called with the <code>new</code> keyword, the function will be used as a constructor.</p>
<p><code>new</code> operator will do the following things:</p>
<ol>
<li><p>It creates a new object.</p>
</li>
<li><p>It sets this new object's internal, inaccessible, <code>[[prototype]]</code> (i.e. <code>__proto__</code>) property to be the constructor function's external, accessible, <code>prototype</code> object (every function object automatically has a <code>prototype</code> property).</p>
</li>
<li><p>It makes the <code>this</code> variable point to the newly created object.</p>
</li>
<li><p>It executes the constructor function, using the newly created object whenever <code>this</code> is mentioned.</p>
</li>
<li><p>It returns the newly created object, unless the constructor function returns a non-<code>null</code> object reference. In this case, that object reference is returned instead.</p>
</li>
</ol>
<blockquote>
<p>Note - Classes can only be instantiated with the <code>new</code> operator — attempting to call a class without <code>new</code> will throw a <code>TypeError</code>.</p>
</blockquote>
<h3>The <code>new</code> with constructor functions</h3>
<p><strong>Constructor functions</strong> in JavaScript are regular functions designed to create and initialize multiple objects with shared properties and methods.</p>
<p>Creating an object with a user-defined constructor function requires two steps:</p>
<ol>
<li><p>Define the object type by writing a function that specifies its name and properties. For example, a constructor function to create an object <code>Person</code> might look like this:</p>
<pre><code class="language-javascript">function Person(name,email){
this.name = name;
this.email.email;
}
</code></pre>
</li>
<li><p>Create an instance of the object with <code>new</code>.</p>
<pre><code class="language-javascript">const mukul = new Person("Mukul","mukul123@gmail.com");
</code></pre>
</li>
</ol>
<h3>The <code>new</code> with classes</h3>
<pre><code class="language-javascript">class Person {
  constructor(name) {
    this.name = name;
  }
  greet() {
    console.log(`Hello, my name is ${this.name}`);
  }
}

const p = new Person("Mukul");
p.greet(); // Hello, my name is Mukul
</code></pre>
<h3><strong>The Object Creation Process and the</strong> <code>new</code> <strong>Links Prototypes</strong></h3>
<p>In the object creation with the new keyword , the js perform the five steps.</p>
<ol>
<li><p><strong>Creates a brand new empty object</strong>  </p>
<p><code>{}</code> — let’s call it <code>newObj</code>.</p>
</li>
<li><p><strong>Links the new object’s prototype</strong>  </p>
<p>Sets <code>newObj.__proto__</code> (or more accurately, <code>[[Prototype]]</code>) to <code>Person.prototype</code>.</p>
</li>
<li><p><strong>Binds</strong> <code>this</code> <strong>to the new object</strong>  </p>
<p>Inside the constructor function, <code>this</code> now refers to <code>newObj</code>.</p>
</li>
<li><p><strong>Executes the constructor body</strong>  </p>
<p>The code inside <code>Person()</code> runs, attaching <code>name</code> and <code>email</code> value to <code>newObj</code>.</p>
</li>
<li><p><strong>Returns the new object</strong> (automatically)  </p>
<p>No need to mention <code>return</code> explicitly, JavaScript returns <code>newObj</code> for you automatically and implicitly.</p>
</li>
</ol>
<p>And in the new prototype linking process, every instance created with <code>new Person()</code> has <code>instance.__proto__ = Person.prototype</code>.</p>
]]></content:encoded></item><item><title><![CDATA[Callbacks in JavaScript: Why They Exist
]]></title><description><![CDATA[Hello guys, in this article we are going to learn about the callback functions in the js, what are they , why we use them and the problems we face while using them.
Callback function
A callback functi]]></description><link>https://blogs.mukuldev.in/callbacks-in-javascript-why-they-exist</link><guid isPermaLink="true">https://blogs.mukuldev.in/callbacks-in-javascript-why-they-exist</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[callbacks]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sun, 26 Apr 2026 19:01:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/99988341-8404-42ea-aaf4-c94b3ec34f50.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello guys, in this article we are going to learn about the callback functions in the js, what are they , why we use them and the problems we face while using them.</p>
<h3>Callback function</h3>
<p><em>A</em> <em><strong>callback function</strong></em> <em>is a function passed into another function as an argument</em>, <em>which is then invoked inside the outer function to complete some kind of action.</em></p>
<p>There are two ways in which the callback may be called: <em><mark class="bg-yellow-200 dark:bg-yellow-500/30">synchronous</mark></em> <mark class="bg-yellow-200 dark:bg-yellow-500/30">and </mark> <em><mark class="bg-yellow-200 dark:bg-yellow-500/30">asynchronous</mark></em><mark class="bg-yellow-200 dark:bg-yellow-500/30">.</mark> Synchronous callbacks are called immediately after the invocation of the outer function, while asynchronous callbacks are called at some point later, after an asynchronous operation has completed.</p>
<pre><code class="language-javascript">let value = 1;

function doSomething(callback) {

// synchromous execution
 callback();

// asynchronous execution
setTimeout(callback,0);
}

doSomething(() =&gt; {
  value = 2;
});
console.log(value); // 1 or 2?
</code></pre>
<p>Here , in this example the <code>callback</code> is executed <code>synchronously</code> and the <code>output</code> will be <code>2</code>.</p>
<blockquote>
<p>Note - Examples of synchronous callbacks include the callbacks passed to <a href="http://Array.prototype.map"><code>Array.prototype.map</code></a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map"><code>()</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach"><code>Array.prototype.forEach()</code></a>, etc. Examples of asynchronous callbacks include the callbacks passed to <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout"><code>setTimeout()</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then"><code>Promise.prototype.then()</code></a>.</p>
</blockquote>
<h3>Why callbacks are used in asynchronous programming</h3>
<p>JavaScript executes code line by line (synchronously), but sometimes we need to wait for a task to complete . Many operations don't finish instantly like api call , timers, file reading and DB queries. Callbacks let you <strong>continue execution without blocking</strong>, and define <em>what should happen later</em>.</p>
<h3>Callback for async operation</h3>
<pre><code class="language-javascript">console.log("Start");

setTimeout(function () {
    console.log("Inside setTimeout");
}, 2000);

console.log("End");
</code></pre>
<ul>
<li><p>setTimeout() is an asynchronous function that takes a callback to execute after 2 seconds.</p>
</li>
<li><p>The rest of the code continues executing without waiting.</p>
</li>
</ul>
<h3>Callback usage in common scenarios</h3>
<ol>
<li><p><strong>Handling Asynchronous Operations</strong><br />Callbacks are widely used in</p>
<ul>
<li><p>API requests (fetching data)</p>
</li>
<li><p>Reading files (Node.js file system)</p>
</li>
<li><p>Event listeners (clicks, keyboard inputs)</p>
</li>
<li><p>Database queries (retrieving data)</p>
</li>
</ul>
</li>
<li><p><strong>Callbacks in Functions Handling Operations</strong><br />When a function needs to execute different behaviors based on input, callbacks make the function flexible.</p>
<pre><code class="language-javascript">function calc(a, b, callback) {
    return callback(a, b);
}

function add(x, y) {
    return x + y;
}

function mul(x, y) {
    return x * y;
}

console.log(calc(5, 3, add));    
console.log(calc(5, 3, mul));

// calculate() receives two numbers and a function (add or multiply).

// The passed function is executed inside calculate().
</code></pre>
</li>
<li><p><strong>Callbacks in Event Listeners</strong><br />JavaScript is event-driven, and callbacks handle user interactions like clicks and key presses.</p>
<pre><code class="language-javascript">document
.getElementById("myButton")
.addEventListener("click", function () {
    console.log("Button clicked!");
});
</code></pre>
</li>
<li><p><strong>Callbacks in API Calls (Fetching Data)</strong><br />Callbacks are useful when retrieving data from APIs.</p>
<pre><code class="language-javascript">function fetch(callback) {
    fetch("https://jsonplaceholder.typicode.com/todos/1")
        .then(response =&gt; response.json())
        .then(data =&gt; callback(data))
        .catch(error =&gt; console.error("Error:", error));
}

function handle(data) {
    console.log("Fetched Data:", data);
}

fetch(handle);
</code></pre>
</li>
</ol>
<h2><strong>Problems with Callbacks</strong></h2>
<p>Callbacks are powerful, but they come with some real pain points—especially as your app grows.</p>
<ol>
<li><p><strong>Callback Hell (Nested Callbacks)</strong></p>
<pre><code class="language-javascript">function step1(callback) {
    setTimeout(() =&gt; {
        console.log("Step 1 completed");
        callback();
    }, 1000);
}

function step2(callback) {
    setTimeout(() =&gt; {
        console.log("Step 2 completed");
        callback();
    }, 1000);
}

function step3(callback) {
    setTimeout(() =&gt; {
        console.log("Step 3 completed");
        callback();
    }, 1000);
}

step1(() =&gt; {
    step2(() =&gt; {
        step3(() =&gt; {
            console.log("All steps completed");
        });
    });
});
</code></pre>
<p>As the number of steps increases, the nesting grows deeper, making the code difficult to manage.</p>
</li>
<li><p><strong>Error Handling Issues in Callbacks</strong></p>
<pre><code class="language-javascript">function divide(a, b, callback) {
    if (b === 0) {
        callback(new Error("Cannot divide by zero"), null);
    } else {
        callback(null, a / b);
    }
}

function result(error, result) {
    if (error) {
        console.log("Error:", error.message);
    } else {
        console.log("Result:", result);
    }
}

divide(10, 2, result);
divide(10, 0, result);
</code></pre>
</li>
</ol>
<p>The main pain-point to work with callback is the code readability . It is majorly affected by the callbacks and can become much difficult to use the callbacks.<br />We can use the promises or async/await as the callbacks alternative.</p>
]]></content:encoded></item><item><title><![CDATA[Array Flatten in JavaScript]]></title><description><![CDATA[Hi everyone , in this article we are going to explore the flat method of the Array instance, the nested arrays , how flatterning the array is useful and lot more.
What are the nested arrays
Nested arr]]></description><link>https://blogs.mukuldev.in/array-flatten-in-javascript</link><guid isPermaLink="true">https://blogs.mukuldev.in/array-flatten-in-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[flatten array]]></category><category><![CDATA[chaicode webdev cohort 2026]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Thu, 23 Apr 2026 19:22:47 GMT</pubDate><content:encoded><![CDATA[<p>Hi everyone , in this article we are going to explore the flat method of the <code>Array</code> instance, the nested arrays , how flatterning the array is useful and lot more.</p>
<h3>What are the nested arrays</h3>
<p>Nested arrays are simply <strong>arrays inside other arrays</strong>.</p>
<p>Example :</p>
<pre><code class="language-javascript">let numbers = [[1, 2], [3, 4], [5, 6]];
</code></pre>
<blockquote>
<p>Here in this example, there are three arrays inside the one main array.</p>
<p>The outer array :</p>
<pre><code class="language-javascript">[[1, 2], [3, 4], [5, 6]]
</code></pre>
<p>The inner arrays :</p>
<pre><code class="language-javascript">[1, 2]
[3, 4]
[5, 6]
</code></pre>
</blockquote>
<h3>Why flattening arrays is useful</h3>
<p>Flattening arrays means converting a <strong>nested array (arrays inside arrays)</strong> into a <strong>simple flat structure array.</strong> It sounds simple, but it solves a lot of practical problems.</p>
<blockquote>
<p>Most array methods in JavaScript (<code>map</code>, <code>filter</code>, <code>reduce</code>) expect a <strong>flat structure</strong>.</p>
</blockquote>
<p>Example :</p>
<pre><code class="language-javascript">let users = [
  { name: "A", posts: ["p1", "p2"] },
  { name: "B", posts: ["p3"] }
];

// In javascript we have flat function to flattern the array.
let allPosts = users.map(u =&gt; u.posts).flat();
// ["p1", "p2", "p3"]
</code></pre>
<h3>Different approaches to flatten arrays</h3>
<h3>1. <code>Array.prototype.flat()</code></h3>
<p>The <code>flat()</code> method of <code>Array</code> instances creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.</p>
<p>Example :</p>
<pre><code class="language-javascript">const arr1 = [0, 1, 2, [3, 4]];

console.log(arr1.flat());
// expected output: Array [0, 1, 2, 3, 4]

const arr2 = [0, 1, [2, [3, [4, 5]]]];

console.log(arr2.flat());
// expected output: Array [0, 1, 2, Array [3, Array [4, 5]]]

console.log(arr2.flat(2));
// expected output: Array [0, 1, 2, 3, Array [4, 5]]

console.log(arr2.flat(Infinity));
// expected output: Array [0, 1, 2, 3, 4, 5]
</code></pre>
<h3>2. Using Recursion</h3>
<p>Recursion involves a function calling itself to break down nested arrays until only primitive values remain. This method is readable but can cause <strong>stack overflow errors</strong> for extremely deep arrays.</p>
<pre><code class="language-javascript">function flattenRecursive(arr) {
  let result = [];
  for (let i = 0; i &lt; arr.length; i++) {
    if (Array.isArray(arr[i])) {
      result = result.concat(flattenRecursive(arr[i]));
    } else {
      result.push(arr[i]);
    }
  }
  return result;
}   
</code></pre>
<blockquote>
<p>In this example, we are runningthe loop over the outer most array till its length. Inside that we are handling the array seperately. If on any index the strucutre is of type array again return the same function with the new nested array.</p>
</blockquote>
<h3>3.<strong>Iterative Approach (Stack)</strong></h3>
<p>An iterative approach uses a <strong>stack</strong> (last-in, first-out) to handle nesting without recursion, avoiding stack overflow issues. It processes elements by popping from the stack and pushing non-array items to the result.</p>
<pre><code class="language-javascript">function flattenIterative(arr) {
  const stack = [...arr];
  const result = [];
  while (stack.length &gt; 0) {
    const item = stack.pop();
    if (Array.isArray(item)) {
      stack.push(...item); // Unwrap and push back
    } else {
      result.push(item);
    }
  }
  return result.reverse(); // Reverse to maintain original order
}   
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Linux File System Hunting]]></title><description><![CDATA[Like many students, I started my journey with Windows. It worked, but it always felt like a black box — things happened behind the scenes, and I had little visibility into how the system actually work]]></description><link>https://blogs.mukuldev.in/linux-file-system-hunting</link><guid isPermaLink="true">https://blogs.mukuldev.in/linux-file-system-hunting</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[linux-file-system]]></category><category><![CDATA[Linux]]></category><category><![CDATA[chaicode webdev cohort 2026]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Wed, 22 Apr 2026 17:45:14 GMT</pubDate><content:encoded><![CDATA[<p>Like many students, I started my journey with Windows. It worked, but it always felt like a black box — things happened behind the scenes, and I had little visibility into how the system actually worked.</p>
<p>That curiosity led me to Linux.</p>
<p>What makes Linux different is not just that it's popular among developers or widely used on servers, but that it exposes its inner workings in a surprisingly transparent way. Almost everything — from running processes to hardware devices — is represented through the filesystem.</p>
<p>In this article, I explore the Linux filesystem not as a collection of folders, but as a map of how the operating system functions internally. By investigating key directories, I discovered how Linux handles configuration, networking, processes, and system behavior — all through files.</p>
<h3><strong>Introduction to the Linux Filesystem</strong></h3>
<p>At its core, the Linux filesystem is a way of organizing data and files on a storage device. Unlike operating systems like Windows, Linux treats everything as a file—whether it's a directory, a hardware device, or even an active process. This unified approach simplifies interactions and makes the system highly flexible.</p>
<p>The Linux filesystem is hierarchical, meaning it has a root directory (<code>/</code>) from which all other files and directories branch out, forming a tree-like structure. This structure is consistent across all Linux distributions, making it easier to navigate and manage multiple systems.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/23e0c1c8-d24d-4451-9216-0df7c558f07a.png" alt="" style="display:block;margin:0 auto" />

<h3><a href="https://dev.to/prodevopsguytech/understanding-the-linux-filesystem-an-in-depth-guide-for-devops-engineers-ona#2-filesystem-hierarchy-standard-fhs"><strong>Filesystem Hierarchy Standard (FHS)</strong></a></h3>
<p>The Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Linux systems. Adherence to FHS ensures that software behaves predictably across different Linux distributions.</p>
<p>The root directory (<code>/</code>) serves as the starting point of the filesystem. Key subdirectories include:</p>
<ul>
<li><p><code>/bin</code>: Essential command binaries, like <code>ls</code>, <code>cp</code>, and <code>mv</code>.</p>
</li>
<li><p><code>/boot</code>: Bootloader files, including the kernel.</p>
</li>
<li><p><code>/dev</code>: Device files representing hardware components.</p>
</li>
<li><p><code>/etc</code>: Configuration files for the system.</p>
</li>
<li><p><code>/home</code>: User home directories.</p>
</li>
<li><p><code>/lib</code>: Essential shared libraries.</p>
</li>
<li><p><code>/mnt</code>: Temporary mount points for filesystems.</p>
</li>
<li><p><code>/opt</code>: Optional software packages.</p>
</li>
<li><p><code>/proc</code>: Virtual filesystem providing process and kernel information.</p>
</li>
<li><p><code>/root</code>: Home directory for the root user.</p>
</li>
<li><p><code>/sbin</code>: System binaries, typically for administrative tasks.</p>
</li>
<li><p><code>/tmp</code>: Temporary files.</p>
</li>
<li><p><code>/usr</code>: Secondary hierarchy for user programs and data.</p>
</li>
<li><p><code>/var</code>: Variable data files like logs, databases, and email.</p>
</li>
</ul>
<h3><strong>Important Directories and Their Purposes</strong></h3>
<p>Each directory in the Linux filesystem has a specific role. Here’s a deeper look into some of the most critical directories:</p>
<ul>
<li><p><code>/</code> <strong>(Root Directory)</strong>: The starting point of the filesystem. All other directories and files branch off from here.</p>
</li>
<li><p><code>/bin</code>: Contains essential command binaries needed for the system to function in single-user mode. These are available to all users.</p>
</li>
<li><p><code>/sbin</code>: Similar to <code>/bin</code>, but contains system binaries that are typically used by the root user for administrative tasks.</p>
</li>
<li><p><code>/lib</code>: Contains shared libraries required by the binaries in <code>/bin</code> and <code>/sbin</code>.</p>
</li>
<li><p><code>/usr</code>: A secondary hierarchy that contains user programs, libraries, documentation, and more. It’s split into subdirectories like <code>/usr/bin</code>, <code>/usr/sbin</code>, and <code>/usr/lib</code>.</p>
</li>
<li><p><code>/var</code>: Stores variable data like logs, databases, and spools. This directory often grows in size over time.</p>
</li>
<li><p><code>/etc</code>: The nerve center for system configuration files. Nearly every service or application has a configuration file located here.</p>
</li>
<li><p><code>/home</code>: Contains personal directories for each user. This is where users store their personal files and directories.</p>
</li>
<li><p><code>/proc</code>: A virtual filesystem that provides an interface to kernel data structures. It’s used to access process information, kernel parameters, and more.</p>
</li>
<li><p><code>/dev</code>: Contains device files that represent hardware components. These files act as interfaces to the corresponding hardware.</p>
</li>
</ul>
<h3><a href="https://dev.to/prodevopsguytech/understanding-the-linux-filesystem-an-in-depth-guide-for-devops-engineers-ona#6-file-permissions-and-ownership"><strong>File Permissions and Ownership</strong></a></h3>
<p>Linux employs a robust permissions system that controls access to files and directories. Each file has three sets of permissions for the owner, the group, and others:</p>
<ul>
<li><p><strong>Read (</strong><code>r</code><strong>)</strong>: Permission to read the contents of the file.</p>
</li>
<li><p><strong>Write (</strong><code>w</code><strong>)</strong>: Permission to modify the file.</p>
</li>
<li><p><strong>Execute (</strong><code>x</code><strong>)</strong>: Permission to execute the file as a program.</p>
</li>
</ul>
<p>Permissions are represented by a combination of letters (<code>r</code>, <code>w</code>, <code>x</code>) or their corresponding octal numbers (4 for read, 2 for write, 1 for execute).</p>
<p>For example, the permission <code>rwxr-xr--</code> means:</p>
<ul>
<li><p><strong>Owner</strong>: Read, write, execute</p>
</li>
<li><p><strong>Group</strong>: Read, execute</p>
</li>
<li><p><strong>Others</strong>: Read only</p>
</li>
</ul>
<p>Understanding and managing permissions is crucial for maintaining system security and ensuring that users have appropriate access levels.</p>
<h3><a href="https://dev.to/prodevopsguytech/understanding-the-linux-filesystem-an-in-depth-guide-for-devops-engineers-ona#7-mounting-and-unmounting-filesystems"><strong>Mounting and Unmounting Filesystems</strong></a></h3>
<p>Mounting is the process of making a filesystem accessible at a certain point in the directory tree. The mount point is typically an empty directory where the filesystem appears to reside.</p>
<ul>
<li><strong>Mount Command</strong>: Used to attach a filesystem to a specified directory.</li>
</ul>
<pre><code class="language-shell">  mount /dev/sdb1 /mnt
</code></pre>
<ul>
<li><strong>Unmount Command</strong>: Used to detach a filesystem from the directory tree.</li>
</ul>
<pre><code class="language-plaintext">  umount /mnt
</code></pre>
<p>Mounting is essential when working with removable media, network shares, or additional storage devices. Properly mounting and unmounting filesystems prevents data corruption and ensures system stability.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Objects in JavaScript]]></title><description><![CDATA[Hey there, in this article we learn about the objects in js, why objects are being used, ohw to loop over the objects, different methods to handle the looping on object keys,values and complete single]]></description><link>https://blogs.mukuldev.in/understanding-objects-in-javascript</link><guid isPermaLink="true">https://blogs.mukuldev.in/understanding-objects-in-javascript</guid><category><![CDATA[Objects]]></category><category><![CDATA[js]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sun, 15 Mar 2026 00:34:24 GMT</pubDate><content:encoded><![CDATA[<p>Hey there, in this article we learn about the objects in js, why objects are being used, ohw to loop over the objects, different methods to handle the looping on object keys,values and complete single entry.</p>
<h3>What are Objects ?</h3>
<p><strong>Objects in JavaScript</strong> are a fundamental data type used to store collections of key-value pairs and represent complex entities</p>
<p>Example information about a person:</p>
<pre><code class="language-plaintext">Name → Rahul
Age → 22
City → Delhi
</code></pre>
<blockquote>
<p>Instead of storing these values in separate variables, we can group them together inside an <strong>object</strong>.</p>
</blockquote>
<h3>Why Do We Need Objects?</h3>
<p>Objects help us organize <strong>related data in a structured way</strong>.</p>
<pre><code class="language-javascript">// without object
let name = "Rahul";
let age = 22;
let city = "Delhi";

// with object
let person = {
  name: "Rahul",
  age: 22,
  city: "Delhi"
};
</code></pre>
<h3>Creating an Object</h3>
<p>Objects are created using <strong>curly braces</strong> <code>{}</code>. Inside the braces, we define <strong>key-value pairs</strong>.</p>
<h3>Syntax</h3>
<pre><code class="language-javascript">let objectName = {
  key: value
};
</code></pre>
<h3>Accessing Object Properties</h3>
<p>There are <strong>two ways</strong> to access object properties.</p>
<h3>Dot Notation</h3>
<p>This is the most common method.</p>
<pre><code class="language-javascript">let person = {
  name: "Rahul",
  age: 22,
  city: "Delhi"
};

console.log(person.name); // Rahul
console.log(person.age); // 22
</code></pre>
<h3>Bracket Notation</h3>
<p>Bracket notation uses square brackets.</p>
<pre><code class="language-javascript">console.log(person["city"]);
</code></pre>
<h3>Updating Object Properties</h3>
<p>Object values can be updated easily.</p>
<pre><code class="language-javascript">let person = {
  name: "Rahul",
  age: 22
};

person.age = 23;

console.log(person.age); // 23
</code></pre>
<h3>Adding New Properties</h3>
<p>We can add new properties to an object anytime.</p>
<pre><code class="language-javascript">let person = {
  name: "Rahul",
  age: 22
};

person.city = "Mumbai";

console.log(person); // { name: "Rahul", age: 22, city: "Mumbai" }
</code></pre>
<h3>Deleting Properties</h3>
<p>To remove a property, we use the <strong>delete</strong> keyword.</p>
<pre><code class="language-javascript">let person = {
  name: "Rahul",
  age: 22,
  city: "Delhi"
};

delete person.city;

console.log(person); // { name: "Rahul", age: 22 }
</code></pre>
<h3>Looping Through Object Keys</h3>
<p>We can loop through object properties using a <strong>for...in loop</strong>.</p>
<h3>Example</h3>
<pre><code class="language-javascript">let person = {
  name: "Rahul",
  age: 22,
  city: "Delhi"
};

for (let key in person) {
  console.log(key, person[key]);
} 
// Expected Output--
// name Rahul
// age 22
// city Delhi
</code></pre>
<h3>Array vs Object</h3>
<p><strong>Arrays</strong> store ordered collections of values using <strong>numeric indices</strong> (starting from 0). They are ideal for lists where <strong>order matters</strong>, such as a sequence of numbers, strings, or objects.</p>
<p><strong>Objects</strong> store data as <strong>key-value pairs</strong>, where keys are typically strings (or symbols) and values can be any data type. They are used to represent <strong>entities</strong> with properties, like a person, car, or configuration.</p>
]]></content:encoded></item><item><title><![CDATA[Arrow Functions in JavaScript]]></title><description><![CDATA[Hey guys , in this article we learn everything about the arrow function in js, how it is different from the normal function expression. so, let start.
What Are Arrow Functions?
Arrow functions are a s]]></description><link>https://blogs.mukuldev.in/arrow-functions-in-javascript</link><guid isPermaLink="true">https://blogs.mukuldev.in/arrow-functions-in-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[#arrowfunction]]></category><category><![CDATA[js functions]]></category><category><![CDATA[js-arrow-functions]]></category><category><![CDATA[js]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 14 Mar 2026 23:43:14 GMT</pubDate><content:encoded><![CDATA[<p>Hey guys , in this article we learn everything about the arrow function in js, how it is different from the normal function expression. so, let start.</p>
<h3>What Are Arrow Functions?</h3>
<p>Arrow functions are a <strong>shorter and cleaner way to write functions in JavaScript</strong>. They were introduced in <strong>ES6 (ECMAScript 2015)</strong> to make function syntax <strong>simpler and more readable</strong>. Instead of using the <code>function</code> keyword, arrow functions use the <strong>arrow (</strong><code>=&gt;</code><strong>) syntax</strong>.</p>
<p><strong>Example -</strong></p>
<pre><code class="language-javascript">// normal function expression. 
function add(a, b) {
  return a + b;
}

// arrow function expression
const add = (a, b) =&gt; {
  return a + b;
};
</code></pre>
<blockquote>
<p>Both functions perform the <strong>same task</strong>, but the arrow function version is <strong>shorter and modern</strong>.</p>
</blockquote>
<h3>Arrow Function syntax</h3>
<pre><code class="language-javascript">() =&gt; expression

param =&gt; expression

(param) =&gt; expression

(param1, paramN) =&gt; expression

() =&gt; {
  statements
}

param =&gt; {
  statements
}

(param1, paramN) =&gt; {
  statements
}
</code></pre>
<h3>Converting function Expression to Arrow function</h3>
<pre><code class="language-javascript">// Traditional anonymous function
(function (a) {
  return a + 100;
});

// 1. Remove the word "function" and place arrow between the argument and opening body brace
(a) =&gt; {
  return a + 100;
};

// 2. Remove the body braces and word "return" — the return is implied.
(a) =&gt; a + 100;

// 3. Remove the parameter parentheses
a =&gt; a + 100;
</code></pre>
<pre><code class="language-javascript">// Traditional anonymous function
(function (a, b) {
  return a + b + 100;
});

// Arrow function
(a, b) =&gt; a + b + 100;

const a = 4;
const b = 2;

// Traditional anonymous function (no parameters)
(function () {
  return a + b + 100;
});

// Arrow function (no parameters)
() =&gt; a + b + 100;
</code></pre>
<h3>Implicit Return vs Explicit Return</h3>
<p>When we use <code>{}</code>, we must use the <code>return</code> keyword.</p>
<pre><code class="language-javascript">// explicit return
const add = (a, b) =&gt; {
  return a + b;
};

// this same arrow function can be converted to something less.
// implicit return
const add = (a,b) =&gt; a + b;
</code></pre>
<h3>Conclusion</h3>
]]></content:encoded></item><item><title><![CDATA[JavaScript Operators]]></title><description><![CDATA[In this article we learn about the different types of operators in js, how to use them with different types of operands and how the operators behave differently with different data types.
What Are Ope]]></description><link>https://blogs.mukuldev.in/javascript-operators</link><guid isPermaLink="true">https://blogs.mukuldev.in/javascript-operators</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Operators]]></category><category><![CDATA[js]]></category><category><![CDATA[Js operators]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 14 Mar 2026 23:10:53 GMT</pubDate><content:encoded><![CDATA[<p>In this article we learn about the different types of operators in js, how to use them with different types of operands and how the operators behave differently with different data types.</p>
<h3>What Are Operators?</h3>
<p>JavaScript operators are symbols or keywords used to perform operations on values and variables. They are the building blocks of JavaScript expressions and can manipulate data in various ways.</p>
<h3><strong>Arithmetic Operators</strong></h3>
<p>Arithmetic operators perform mathematical calculations like addition, subtraction, multiplication, etc.</p>
<pre><code class="language-javascript">const sum = 5 + 3; // Addition
const diff = 10 - 2; // Subtraction
const p = 4 * 2; // Multiplication
const q = 8 / 2; // Division
console.log(sum, diff, p, q);
</code></pre>
<h3><strong>Assignment Operators</strong></h3>
<p><strong>Assignment Operators</strong> are used to assign values to variables. They can also perform operations like addition or multiplication while assigning the value.</p>
<pre><code class="language-javascript">let n = 10;
n += 5;
n *= 2;
console.log(n);
</code></pre>
<blockquote>
<p>+= is the short hand operator which adds and assigns the result to the variable.<br />-= is the short hand operator which subtracts and assigns the result to the variable.<br />and same for the rest like (*= , /+ etc.)</p>
</blockquote>
<h3><strong>Comparison Operators</strong></h3>
<p><strong>Comparison operators</strong> compare two values and return a boolean (true or false). They are useful for making decisions in conditional statements.</p>
<pre><code class="language-javascript">console.log(10 &gt; 5);
console.log(10 === "10");
</code></pre>
<blockquote>
<p>-- &gt; checks if the left value is greater than the right.<br />-- === checks for strict equality (both type and value).<br />-- Other operators include &lt;, &lt;=, &gt;=, and !==.</p>
</blockquote>
<h3><strong>Logical Operators</strong></h3>
<p><strong>Logical operators</strong> are mainly used to perform the logical operations that determine the equality or difference between the values.</p>
<pre><code class="language-javascript">const a = true, b = false;
console.log(a &amp;&amp; b); // Logical AND
console.log(a || b); // Logical OR
</code></pre>
<blockquote>
<p>-- &amp;&amp; returns true if both operands are true.<br />-- || returns true if at least one operand is true.<br />-- ! negates the boolean value.</p>
</blockquote>
<h3><strong>Bitwise Operators</strong></h3>
<p><strong>Bitwise Operators</strong> perform operations on binary representations of numbers.</p>
<pre><code class="language-javascript">const res = 5 &amp; 1; // Bitwise AND
console.log(res);
</code></pre>
<blockquote>
<p>-- &amp; performs a bitwise AND.<br />-- | performs a bitwise OR.<br />-- ^ performs a bitwise XOR.<br />-- ~ performs a bitwise NOT.</p>
</blockquote>
<h3>Difference between == and ===</h3>
<p><code>==</code> compares values <strong>after converting their types if needed</strong>.</p>
<p><code>===</code> compares <strong>both value and type</strong>.</p>
<pre><code class="language-javascript">console.log(5 == "5"); // true
// == does not check the types of the both operands, olny check the value

console.log(5 === "5"); // false
// === does check both the types and value of the operands
</code></pre>
<h3>Conclusion</h3>
<p>Operators are fundamental building blocks in JavaScript that allow us to <strong>perform calculations, compare values, and control program logic</strong>.</p>
<p>In this article, we explored several types of operators, including:</p>
<ul>
<li><p>Arithmetic operators for performing calculations</p>
</li>
<li><p>Comparison operators for evaluating conditions</p>
</li>
<li><p>Logical operators for combining conditions</p>
</li>
<li><p>Assignment operators for storing and updating values</p>
</li>
<li><p>BItwise operators for the binary-level operations</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Control Flow in JavaScript]]></title><description><![CDATA[In this article, we learn about the control flow in the programming , why it exists and what are the different ways with which we can handle the control flow of the program.
What is Control Flow?
Cont]]></description><link>https://blogs.mukuldev.in/control-flow-in-javascript</link><guid isPermaLink="true">https://blogs.mukuldev.in/control-flow-in-javascript</guid><category><![CDATA[control flow]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[js]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 14 Mar 2026 22:08:11 GMT</pubDate><content:encoded><![CDATA[<p>In this article, we learn about the control flow in the programming , why it exists and what are the different ways with which we can handle the control flow of the program.</p>
<h2>What is Control Flow?</h2>
<p><strong>Control flow</strong> refers to the <strong>order in which a program executes its instructions</strong>.</p>
<p>Normally, JavaScript executes code <strong>line by line from top to bottom</strong>. But in many situations, we need the program to <strong>make decisions</strong> and run different code based on conditions.</p>
<p>This is where <strong>control flow statements</strong> come into play.</p>
<h3>Real-Life Example</h3>
<p>Imagine deciding what to wear:</p>
<pre><code class="language-plaintext">If it is raining → take an umbrella
Else → wear sunglasses
</code></pre>
<h3><code>if</code> statement</h3>
<p>The <code>if</code> statement is used when we want to execute 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>
<h3>Example</h3>
<pre><code class="language-javascript">let age = 20;

if (age &gt;= 18) {
  console.log("You can vote");
}
</code></pre>
<h3><code>if...else</code> Statement</h3>
<p>Sometimes we want to run <strong>one block of code if the condition is true</strong> and <strong>another block if it is false</strong>.</p>
<h3>Syntax</h3>
<pre><code class="language-plaintext">if (condition) {
  // runs if condition is true
} else {
  // runs if condition is false
}
</code></pre>
<pre><code class="language-javascript">let age = 16;

if (age &gt;= 18) {
  console.log("You can vote");
} else {
  console.log("You are too young to vote");
}
</code></pre>
<h3><code>else if</code> Ladder</h3>
<p>When we need to check <strong>multiple conditions</strong>, we use <code>else if</code>.</p>
<h3>Syntax</h3>
<pre><code class="language-plaintext">if (condition1) {
  // code
} else if (condition2) {
  // code
} else {
  // default code
}
</code></pre>
<pre><code class="language-javascript">let marks = 75;

if (marks &gt;= 90) {
  console.log("Grade A");
} else if (marks &gt;= 70) {
  console.log("Grade B");
} else if (marks &gt;= 50) {
  console.log("Grade C");
} else {
  console.log("Fail");
}
</code></pre>
<h3><code>switch</code> Statement</h3>
<p>The <code>switch</code> statement is used when we want to <strong>compare one value against multiple possible options</strong>.</p>
<h3>Syntax</h3>
<pre><code class="language-plaintext">switch (expression) {
  case value1:
    // code
    break;

  case value2:
    // code
    break;

  default:
    // code
}
</code></pre>
<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><code>break</code> Statement</h3>
<p>The <code>break</code> statement <strong>stops the switch execution</strong>.</p>
<p>Without <code>break</code>, JavaScript continues executing the next cases.</p>
<p>Example without break:</p>
<pre><code class="language-javascript">let day = 1;

switch (day) {
  case 1:
    console.log("Monday");

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

// without break
// o/p will be

// Monday
// Tuesday
</code></pre>
<h3>When to Use <code>switch</code> vs <code>if-else</code></h3>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/2a4f4615-c5e8-4437-9025-8ccca37a5e01.png" alt="" style="display:block;margin:0 auto" />

<h3>Conclusion</h3>
<p>Control flow is an essential part of programming because it allows our programs to <strong>make decisions based on conditions</strong>.</p>
]]></content:encoded></item><item><title><![CDATA[Variables and Data Types in JavaScript]]></title><description><![CDATA[In this article we learn about the variables and data types in js. Difference keywords like var, let, and const which we can use with any variable declaration.
What is a Variable?
A variable is like a]]></description><link>https://blogs.mukuldev.in/variables-and-data-types-in-javascript</link><guid isPermaLink="true">https://blogs.mukuldev.in/variables-and-data-types-in-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[datatypes]]></category><category><![CDATA[variables]]></category><category><![CDATA[js]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 14 Mar 2026 21:49:56 GMT</pubDate><content:encoded><![CDATA[<p>In this article we learn about the variables and data types in js. Difference keywords like var, let, and const which we can use with any variable declaration.</p>
<h3>What is a Variable?</h3>
<p>A <strong>variable</strong> is like a <strong>container used to store information</strong>.</p>
<p>Imagine you have a box labeled <strong>"Name"</strong>. Inside that box, you store the value <strong>"Mukul"</strong>.<br />Later, whenever you need the name, you simply check the box.</p>
<p>In JavaScript, variables work the same way. They store data that your program can use later.</p>
<pre><code class="language-javascript">let name = "Mukul";
</code></pre>
<p>Variables help us <strong>store, reuse, and update information in our programs</strong>. Without variables, we would need to write values repeatedly.</p>
<h3>Declaring Variables in JavaScript</h3>
<p>JavaScript provides three keywords to declare variables: <code>var , let , and const.</code></p>
<pre><code class="language-javascript">var city = "Delhi";
let age = 22;
const country = "India";
// there is some difference between these keywords.
</code></pre>
<h3>Primitive Data Types</h3>
<p>Data types define <strong>what type of data a variable holds</strong>. JavaScript has several primitive data types.</p>
<ol>
<li><h2>String</h2>
</li>
</ol>
<p>The <code>String</code> object is used to represent and manipulate a sequence of characters. Strings are useful for holding data that can be represented in text form.</p>
<p>Example: names, messages, or sentences.</p>
<pre><code class="language-plaintext">const string1 = "A string primitive";
const string2 = 'Also a string primitive';
const string3 = `Yet another string primitive`;
</code></pre>
<ol>
<li><h3>Number</h3>
</li>
</ol>
<p>Numbers represent numeric values. Numbers are most commonly expressed in literal forms like <code>255</code> or <code>3.14159</code>.</p>
<pre><code class="language-javascript">let age = 25;
let price = 199.99;
// JavaScript uses one number type for both integers and decimals.
</code></pre>
<ol>
<li><h3>Boolean</h3>
</li>
</ol>
<p>A <strong>boolean</strong> represents either <strong>true or false</strong>. Booleans are often used in <strong>conditions and decision making</strong>.</p>
<pre><code class="language-javascript">let isStudent = true;
let isLoggedIn = false;
</code></pre>
<ol>
<li><h3>Null</h3>
</li>
</ol>
<p><code>null</code> means the variable currently has <strong>no value assigned intentionally</strong>.</p>
<pre><code class="language-plaintext">let selectedUser = null;
</code></pre>
<ol>
<li><h3>Undefined</h3>
</li>
</ol>
<p><code>undefined</code> means the variable has been <strong>declared but not assigned a value</strong>.</p>
<pre><code class="language-plaintext">let score;

console.log(score); // undefined
</code></pre>
<h3>Difference between <code>var</code>, <code>let</code>, and <code>const</code></h3>
<p><strong>var</strong> is globally scoped, can be redeclared and updated, and is hoisted with a default value of <code>undefined</code>. This can lead to unexpected behavior and bugs.</p>
<p><strong>let</strong> is block-scoped (within <code>{}</code>), cannot be redeclared in the same scope, but can be updated. It is hoisted but remains in a "temporal dead zone" until declared, throwing a <code>ReferenceError</code> if accessed before initialization.</p>
<p><strong>const</strong> is also block-scoped, cannot be redeclared or reassigned after initialization, and must be assigned a value at declaration. While the variable binding is immutable, properties of objects or elements of arrays declared with <code>const</code> can still be modified.</p>
<blockquote>
<p><strong>Note - Use const for values that should not change, let for values that will change</strong>, and avoid <strong>var</strong> in modern JavaScript due to its broader scope and hoisting quirks.</p>
</blockquote>
<h3>What is Scope? (Beginner Explanation)</h3>
<p><strong>Scope defines where a variable can be accessed in the code.</strong> Think of scope like <strong>rooms in a house</strong>.</p>
<p>If a variable is created inside a room, it can only be used inside that room.</p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Arrays 101]]></title><description><![CDATA[In this article, we get to know about the array in js , basics about the array , how to access the elements in the array and a lot more.
What is Array?
The Array object, as with arrays in other progra]]></description><link>https://blogs.mukuldev.in/javascript-arrays-101</link><guid isPermaLink="true">https://blogs.mukuldev.in/javascript-arrays-101</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[array]]></category><category><![CDATA[js]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 14 Mar 2026 20:38:04 GMT</pubDate><content:encoded><![CDATA[<p>In this article, we get to know about the array in js , basics about the array , how to access the elements in the array and a lot more.</p>
<h2><strong>What is Array?</strong></h2>
<p>The <code>Array</code> object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name.</p>
<ul>
<li><p><strong>JavaScript arrays are resizable</strong> and <strong>can contain a mix of different data types.</strong></p>
</li>
<li><p><strong>JavaScript array-copy operations create shallow copies</strong>. (All standard built-in copy operations with <em>any</em> JavaScript objects create shallow copies, rather than deep copies).</p>
</li>
</ul>
<h3>How to Create an Array</h3>
<p>Creating an array is simple. We use square brackets <code>[]</code> and separate our items with commas.</p>
<p>JavaScript</p>
<pre><code class="language-javascript">// Creating an array of favorite fruits
let fruits = ["Apple", "Banana", "Cherry", "Mango"];
</code></pre>
<p>By using one variable (<code>fruits</code>), we’ve successfully grouped four pieces of information together.</p>
<h3>Accessing array elements</h3>
<p>Each element in an array has a <strong>position called an index</strong>. Array indexing starts from 0.</p>
<pre><code class="language-javascript">let fruits = ["Apple", "Banana", "Cherry"];

console.log(fruits[0]); // Apple
console.log(fruits[1]); // Banana
console.log(fruits[2]); // Cherry
</code></pre>
<h3>Changing Array Values</h3>
<p>You can modify any element using its <strong>index</strong>.</p>
<pre><code class="language-javascript">let fruits = ["Apple", "Banana", "Cherry"];

fruits[1] = "Mango";

console.log(fruits);
// ["Apple", "Mango", "Cherry"]
</code></pre>
<h3>Finding Array Length</h3>
<p>To find the total number of elements in an array, we use the <strong>length property</strong>.</p>
<pre><code class="language-plaintext">let fruits = ["Apple", "Banana", "Cherry"];

console.log(fruits.length); // 3
</code></pre>
<h3>Looping Over Arrays</h3>
<p>The real power of arrays comes when you combine them with loops. Instead of writing <code>console.log</code> five times, you can use a <code>for</code> loop to go through the entire collection automatically.</p>
<pre><code class="language-javascript">let colors = ["Red", "Green", "Blue", "Yellow"];

for (let i = 0; i &lt; colors.length; i++) {
    console.log("Color " + i + " is " + colors[i]);
}
</code></pre>
<h3>Conclusion</h3>
<p>At the end, with this article we can learn about the basics of array and can learn about how to acces the element from the array , about indexing and how to loop over the arrays.</p>
]]></content:encoded></item><item><title><![CDATA[Function Declaration vs Function Expression]]></title><description><![CDATA[In JavaScript, a function is a reusable block of code that performs a specific task.
Instead of writing the same code again and again, we create a function and call it whenever we need it.
function ad]]></description><link>https://blogs.mukuldev.in/function-declaration-vs-function-expression</link><guid isPermaLink="true">https://blogs.mukuldev.in/function-declaration-vs-function-expression</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[functions in js]]></category><category><![CDATA[Functional Programming]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 14 Mar 2026 19:11:04 GMT</pubDate><content:encoded><![CDATA[<p>In JavaScript, a <strong>function is a reusable block of code</strong> that performs a specific task.</p>
<p>Instead of writing the same code again and again, we create a function and <strong>call it whenever we need it</strong>.</p>
<pre><code class="language-javascript">function add(a, b) {
  return a + b;
}

console.log(add(2, 3)); // 5
</code></pre>
<p>In this example, we created the function add which accepts two parameters a and b and returns the sum of the two numbers which are given as the arguments.</p>
<h3>Function Declaration</h3>
<p>A <strong>Function Declaration</strong> defines a function using the <code>function</code> keyword with a name.</p>
<pre><code class="language-javascript">function functionName(parameters) {
  // code
}

function multiply(a, b) {
  return a * b;
}

console.log(multiply(4, 5)); // 20
</code></pre>
<h3>Function Expression</h3>
<p>A <strong>Function Expression</strong> stores a function inside a variable.</p>
<pre><code class="language-javascript">const variableName = function(parameters) {
  // code
}

const multiply = function(a, b) {
  return a * b;
};

console.log(multiply(4, 5)); // 20
</code></pre>
<h3>Declaration vs Expression</h3>
<pre><code class="language-javascript">// function declaration
function greet() {
  console.log("Hello");
}

// function expression
const greet = function() {
  console.log("Hello");
};
</code></pre>
<p>Both do the <strong>same job</strong>, but they behave differently during execution.</p>
<h3>Hoisting (Simple Explanation)</h3>
<p><strong>Hoisting</strong> means JavaScript moves certain declarations to the top of the scope before execution.</p>
<pre><code class="language-javascript">// function declaration
sayHello();

function sayHello() {
  console.log("Hello!");
}
// this works fine because function declarations are hoisted.

// function expression
sayHello();

const sayHello = function() {
  console.log("Hello!");
};
// This throws an error because the variable sayHello is not initialized yet.
</code></pre>
<h3>Conclusion</h3>
<p>Both <strong>Function Declarations</strong> and <strong>Function Expressions</strong> allow us to define reusable logic in JavaScript.</p>
<p>The main difference lies in <strong>how JavaScript treats them during execution</strong>.</p>
<ul>
<li><p>Function declarations are <strong>hoisted</strong></p>
</li>
<li><p>Function expressions are <strong>not</strong></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Array Methods You Must Know]]></title><description><![CDATA[Hey there , in this article we would be get to know about some array methods in the javascript, how we can take use of these functions and try to learn about these with the help of basic examples.Meth]]></description><link>https://blogs.mukuldev.in/array-methods-you-must-know</link><guid isPermaLink="true">https://blogs.mukuldev.in/array-methods-you-must-know</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[array]]></category><category><![CDATA[array methods]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 14 Mar 2026 18:34:53 GMT</pubDate><content:encoded><![CDATA[<p>Hey there , in this article we would be get to know about some array methods in the javascript, how we can take use of these functions and try to learn about these with the help of basic examples.<br />Methods to be covered in this article -<br />1. <code>push()</code> and <code>pop()</code><br />2. <code>shift()</code> and <code>unshift()</code><br />3. <code>map()</code><br />4. <code>filter()</code><br />5. <code>reduce()</code><br />6. <code>foreach()</code></p>
<h2>What is Array?</h2>
<p>The <code>Array</code> object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name.</p>
<ul>
<li><p><strong>JavaScript arrays are resizable</strong> and <strong>can contain a mix of different data types.</strong></p>
</li>
<li><p><strong>JavaScript array-copy operations create shallow copies</strong>. (All standard built-in copy operations with <em>any</em> JavaScript objects create shallow copies, rather than deep copies).</p>
</li>
</ul>
<h3>1. Array.prototype.push()</h3>
<p>The <code>push()</code> method of <code>Array</code> instances adds the specified elements to the end of an array and returns the new length of the array.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/0a94a852-f37e-4505-9c38-ca6d795fc369.png" alt="" style="display:block;margin:0 auto" />

<blockquote>
<p>The <code>push()</code> method appends values to an array.</p>
<p><code>Array.prototype.unshift()</code> has similar behavior to <code>push()</code>, but applied to the start of an array.</p>
<p>The <code>push()</code> method is a mutating method. It changes the length and the content of <code>this</code>.</p>
</blockquote>
<h3>2. Array.prototype.pop()</h3>
<p>The <code>pop()</code> method of <code>Array</code> instances removes the <strong>last</strong> element from an array and returns that element. This method changes the length of the array.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/21e21210-b66b-416d-beca-acbf2c349dd6.png" alt="" style="display:block;margin:0 auto" />

<blockquote>
<p>If you call <code>pop()</code> on an empty array, it returns <code>undefined</code>.</p>
<p><code>Array.prototype.shift()</code> has similar behavior to <code>pop()</code>, but applied to the first element in an array.</p>
</blockquote>
<h3>3. Array.prototype.shift()</h3>
<p>The <code>shift()</code> method of <code>Array</code> instances removes the <strong>first</strong> element from an array and returns that removed element. This method changes the length of the array.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/f665cc60-96b3-4189-9185-e8713eaafed3.png" alt="" style="display:block;margin:0 auto" />

<blockquote>
<p>The <code>shift()</code> method shifts all values to the left by 1 and decrements the length by 1, resulting in the first element being removed.</p>
</blockquote>
<h3>4. Array.prototype.unshift()</h3>
<p>The <code>unshift()</code> method of <code>Array</code> instances adds the specified elements to the beginning of an array and returns the new length of the array.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/1b8a760f-719a-4332-87fa-f311b0c2dd93.png" alt="" style="display:block;margin:0 auto" />

<p>The <code>unshift()</code> method inserts the given values to the beginning of an array-like object.</p>
<h3>5. Array.prototype.map()</h3>
<p>The <code>map()</code> method of <code>Array</code> instances creates a new array populated with the results of calling a provided function on every element in the calling array.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/b38de2e7-2df8-4008-9feb-c4339c5a1e6a.png" alt="" style="display:block;margin:0 auto" />

<blockquote>
<p>It takes the callback function as the parameter . A function to execute for each element of the array and then the returned value is added as a single element in the new array.</p>
<p>The callback function can take three parameters -<br />1. <code>element</code> :- The current element being processed in the array.</p>
<p>2. <code>index</code> :- he index of the current element being processed in the array.</p>
<p>3. <code>array</code> :- The array <code>map()</code> was called upon.</p>
<p>It returns the new array with each element being the result of the callback function.</p>
</blockquote>
<h3>6. Array.prototype.filter()</h3>
<p>The <code>filter()</code> method creates a <strong>new array</strong> with all elements that pass the test implemented by a provided function. It does not modify the given array .</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/37c4cac3-faec-4af1-ad6d-be662ca2b4ee.png" alt="" style="display:block;margin:0 auto" />

<p>In the given example , we have the array named <code>words</code> with some strings in it. After that we use the <code>filter</code> function, which is the high order function which takes some other function as the input and returns the new array which satisfy the given condition.<br />Here in this example, all the string having the <code>length &gt; 6</code> will return true and stored in the new array which is return by the <code>filter</code> function after the loop completion.</p>
<h3>7. Array.prototype.reduce()</h3>
<p>The <code>reduce()</code> <strong>function</strong> in JavaScript is <strong>a higher-order method that iloop over an array to reduce it to a single value</strong>.</p>
<p>It applies a callback function to each element, using the return value from the previous iteration as the accumulator for the next. The final accumulated value is returned.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/8fee4f6a-0424-4e98-8c2f-d0006e074795.png" alt="" style="display:block;margin:0 auto" />

<p>It takes two values as the parameter , <code>callback fnc and the result initial value.</code> With the help of the above example we can se that initialvalue of the accumulator is 10. The function loop over the array sum the accumulator and currentValue and finally return the final value.</p>
<h3>8. Array.prototype.forEach()</h3>
<p>The <code>forEach()</code> method of <code>Array</code> instances executes a provided function once for each array element.</p>
<img src="https://cdn.hashnode.com/uploads/covers/63cbeb71587fc59d3cd75412/073bbd3e-a0f8-4b9d-99d8-f9fe985a9bc2.png" alt="" style="display:block;margin:0 auto" />

<blockquote>
<p>Note : There is no way to stop or break a <code>forEach()</code> loop other than by throwing an exception. If you need such behavior, the <code>forEach()</code> method is the wrong tool.</p>
</blockquote>
<p>Conclusion - With this article, we get to know about some of the important function to use with or loop over the array.</p>
<p>Refer the mdn docs for more depper explaination ablout these functions. This article is about to give the basic overview about these functions.</p>
]]></content:encoded></item><item><title><![CDATA[How a Browser Works: A Beginner-Friendly Guide to Browser Internals]]></title><description><![CDATA[A browser is a software application that allows you to access and view websites on the internet. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's scr...]]></description><link>https://blogs.mukuldev.in/how-a-browser-works-a-beginner-friendly-guide-to-browser-internals</link><guid isPermaLink="true">https://blogs.mukuldev.in/how-a-browser-works-a-beginner-friendly-guide-to-browser-internals</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Browser Internals]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sun, 01 Feb 2026 13:03:29 GMT</pubDate><content:encoded><![CDATA[<p>A browser is a software application that allows you to access and view websites on the internet. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's screen.</p>
<p>It retrieves web pages, displays text, images, and videos, and lets you interact with online content.</p>
<h2 id="heading-how-do-browsers-work"><strong>How do Browsers Work?</strong></h2>
<ul>
<li><p>You enter a website address (URL) or click a link.</p>
</li>
<li><p>The browser sends a request to the website’s server.</p>
</li>
<li><p>The server responds by sending the webpage’s data (HTML, CSS, JavaScript, images, etc.).</p>
</li>
<li><p>The browser processes this data and displays the webpage.</p>
</li>
<li><p>You can interact with the page by clicking, scrolling, or entering information.</p>
</li>
</ul>
<p><img src="https://browserstack.wpenginepowered.com/wp-content/uploads/2023/06/How-does-a-Browser-Work.png" alt="How does a Browser Work" class="image--center mx-auto" /></p>
<p><strong>Step 1</strong>: The process begins with Domain Name System (DNS) resolution, where the browser translates the domain name into an IP address to locate the server where the web page is stored.</p>
<p><strong>Step 2</strong>: The browser then sends an HTTP request to the server, specifying the path and parameters of the requested resource.</p>
<p><strong>Step 3</strong>: Once the server receives the request, it sends an HTTP response to the browser containing the requested resource in HTML, CSS, and JavaScript code.</p>
<p><strong>Step 4</strong>: The browser’s rendering engine interprets and renders the code to display the web page on the user’s device.</p>
<p><strong>Step 5</strong>: The CSS stylesheets are applied to format the web page’s content, including fonts, colors, and layout.</p>
<p><strong>Step 6</strong>: The browser may also execute JavaScript code on the web page to add interactivity and dynamic behavior.</p>
<p><strong>Step 7</strong>: As new content is loaded or changes are made to the web page, the browser updates the display accordingly.</p>
<h2 id="heading-features-of-a-browser">Features of a Browser</h2>
<p>Most browsers include standard features such as:</p>
<ul>
<li><p>A <strong>home button</strong> to return to a designated homepage</p>
</li>
<li><p>An <strong>address bar</strong> to enter web <strong>URLs</strong></p>
</li>
<li><p><strong>Back</strong> and <strong>forward</strong> buttons for page navigation</p>
</li>
<li><p>A <strong>refresh</strong> button to reload pages</p>
</li>
<li><p><strong>Stop</strong> to halt page loading</p>
</li>
<li><p><strong>Tabs</strong> for multiple websites in one window</p>
</li>
<li><p><strong>Bookmarks</strong> for saving frequently visited sites</p>
</li>
</ul>
<p>Many browsers support plug-ins to enhance functionality, like adding security features or new capabilities.</p>
<h2 id="heading-components-of-a-browser">Components of a Browser</h2>
<p>Web Browsers consist of 7 different components listed below:</p>
<h4 id="heading-1-user-interface"><strong>1. User Interface</strong></h4>
<p>This component allows end-users to interact with all visual elements available on the web page. The visual elements include the <strong>address bar, home button, next button,</strong> and all other elements that fetch and display the web page requested by the end-user.</p>
<h4 id="heading-2-browser-engine"><strong>2. Browser Engine</strong></h4>
<p>It is a core component of every web browser. The browser engine functions as an intermediary or a bridge between the user interface and the rendering engine. It queries and handles the rendering engine as per the inputs received from the user interface.</p>
<p>The performance and features of a browser engine can greatly impact the user experience of a web browser. A fast and efficient browser engine can help web pages load quickly and smoothly, while a slower or less capable engine may struggle to render complex pages or provide a smooth browsing experience.</p>
<h4 id="heading-3-rendering-engine"><strong>3. Rendering Engine</strong></h4>
<p>As the name suggests, this component is responsible for rendering a specific web page requested by the user on their screen. It interprets HTML and XML documents along with images that are styled or formatted using CSS, and a final layout is generated, which is displayed on the user interface.</p>
<p><strong>Note</strong>: Every browser has its own unique rendering engine. Rendering engines might also differ for different browser versions. The list below mentions browser engines used by a few common browsers:</p>
<ol>
<li><p>Google Chrome and Opera v.15+: <strong>Blink</strong></p>
</li>
<li><p>Internet Explorer: <strong>Trident</strong></p>
</li>
<li><p>Mozilla Firefox: <strong>Gecko</strong></p>
</li>
<li><p>Chrome for iOS and Safari: <strong>WebKit</strong></p>
</li>
</ol>
<h4 id="heading-4-networking"><strong>4. Networking</strong></h4>
<p>This component is responsible for managing network calls using standard protocols like HTTP or FTP. It also looks after security issues associated with internet communication.</p>
<h4 id="heading-5-javascript-interpreter"><strong>5. JavaScript Interpreter</strong></h4>
<p>As the name suggests, it is responsible for parsing and executing the JavaScript code embedded in a website. Once the interpreted results are generated, they are forwarded to the rendering engine for display on the user interface.</p>
<h4 id="heading-6-ui-backend"><strong>6. UI Backend</strong></h4>
<p>This component uses the user interface methods of the underlying operating system. It is mainly used for drawing basic widgets (windows and combo boxes).</p>
<h4 id="heading-7-data-storagepersistence"><strong>7. Data Storage/Persistence</strong></h4>
<p>It is a persistent layer. A web browser needs to store various types of data locally, for example, cookies. As a result, browsers must be compatible with data storage mechanisms such as WebSQL, IndexedDB, FileSystem, etc.</p>
<p>When users type a URL, click links, or utilize features, the front-end requests necessary resources from the back-end. The back-end processes these resources and sends the rendered content back to the front-end for display. This enables smooth navigation and interaction with online content.</p>
<p>Apart from these two major elements, here are the components of a browser.</p>
<p><img src="https://browserstack.wpenginepowered.com/wp-content/uploads/2023/06/Components-of-a-browser.png" alt="Components of a browser" class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769949930462/487d76a1-dd18-4b5f-b614-6713a827bdb4.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[CSS Selectors : Targeting Elements with Precision]]></title><description><![CDATA[CSS Selectors are patterns used in CSS to select and target HTML elements so that styles can be applied to them. They define which elements on a web page should receive specific styling rules.

Used to select HTML elements based on tag name, class, i...]]></description><link>https://blogs.mukuldev.in/css-selectors-targeting-elements-with-precision</link><guid isPermaLink="true">https://blogs.mukuldev.in/css-selectors-targeting-elements-with-precision</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[CSS]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 31 Jan 2026 21:13:50 GMT</pubDate><content:encoded><![CDATA[<p>CSS Selectors are patterns used in CSS to select and target HTML elements so that styles can be applied to them. They define which elements on a web page should receive specific styling rules.</p>
<ul>
<li><p>Used to select HTML elements based on tag name, class, id, or attributes</p>
</li>
<li><p>Help apply styles like color, font, spacing, and layout</p>
</li>
<li><p>Make web pages structured, consistent, and visually appealing</p>
</li>
</ul>
<p>There are mainly 5 types of selectors.</p>
<ol>
<li><h3 id="heading-basic-selectors"><strong>Basic Selectors</strong></h3>
</li>
</ol>
<p>Basic selectors in <strong>CSS</strong> are simple tools used for selecting by <strong>HTML element</strong> name (e.g., h1), class (.class Name), ID (#idName), or universally (* for all elements).</p>
<p><strong>a). Universal Selector (*):</strong> Selects all elements on the page and applies the same style universally.</p>
<p><strong>Example:</strong> Setting the font color for every element.</p>
<pre><code class="lang-xml">* {
    color: red;
}
</code></pre>
<p><strong>b). Element Selector:</strong> Targets all elements of a specific type, such as paragraphs or headers.</p>
<p><strong>Example:</strong> Setting a common font size for all paragraphs</p>
<pre><code class="lang-xml">p {
  font-size: 16px;
}
</code></pre>
<p><strong>c). Class Selector (.)</strong>: Applies styles to elements with a specific <strong>class attribute.</strong></p>
<p><strong>Example:</strong> Making all buttons have a blue background.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</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">style</span>&gt;</span><span class="css">
        <span class="hljs-selector-class">.button</span> {
            <span class="hljs-attribute">background-color</span>: blue;
            <span class="hljs-attribute">color</span>: white;
        }
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</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">button</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"button"</span>&gt;</span>Click Me!<span class="hljs-tag">&lt;/<span class="hljs-name">button</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>d). ID Selector (#)</strong>: Styles a single element identified by its <strong>unique id</strong>.</p>
<p><strong>Example:</strong> changing the background color of a header.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</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">style</span>&gt;</span><span class="css">
        <span class="hljs-selector-id">#header</span> {
            <span class="hljs-attribute">background-color</span>: gray;
        }
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</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">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"header"</span>&gt;</span>This is the header section.<span class="hljs-tag">&lt;/<span class="hljs-name">div</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>
<ol start="2">
<li><h3 id="heading-combinator-selectors"><strong>Combinator Selectors</strong></h3>
</li>
</ol>
<p>Used to define relationships between selectors, allowing you to style elements based on their hierarchy or <strong>positioning</strong> in the document. Common combinators include descendant ( ), child (&gt;), adjacent sibling (+), and general sibling (~).</p>
<p><strong>a). Descendant Selectors:</strong> Targets an element inside another, such as paragraphs inside div <strong>.</strong></p>
<p><strong>Example:</strong> Styling paragraphs inside a div.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</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">style</span>&gt;</span><span class="css">
        <span class="hljs-selector-tag">div</span> <span class="hljs-selector-tag">p</span> {
            <span class="hljs-attribute">color</span>: red;
        }
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</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">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This paragraph inside a div will be red.<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">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>b). <strong>Child Selector (&gt;):</strong> They only affects the <strong>direct child elements</strong> of a parent.</p>
<p><strong>Example:</strong> Styling direct children paragraphs of a div.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</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">style</span>&gt;</span><span class="css">
        <span class="hljs-selector-tag">div</span>&gt;<span class="hljs-selector-tag">p</span> {
            <span class="hljs-attribute">margin-left</span>: <span class="hljs-number">20px</span>;
        }
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</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">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is a direct child and has a left margin.<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 is not a direct child.<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>
<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>
]]></content:encoded></item><item><title><![CDATA[TCP 3-Way Handshake Process]]></title><description><![CDATA[The TCP 3-Way Handshake is a process used by the Transmission Control Protocol (TCP) to establish a reliable connection between a client and a server before data transfer. It ensures that both sides are synchronized and ready to communicate.

Problem...]]></description><link>https://blogs.mukuldev.in/tcp-3-way-handshake-process</link><guid isPermaLink="true">https://blogs.mukuldev.in/tcp-3-way-handshake-process</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[TCP]]></category><category><![CDATA[3-way handshake]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 31 Jan 2026 20:05:32 GMT</pubDate><content:encoded><![CDATA[<p>The TCP 3-Way Handshake is a process used by the Transmission Control Protocol (TCP) to establish a reliable connection between a client and a server before data transfer. It ensures that both sides are synchronized and ready to communicate.</p>
<hr />
<h2 id="heading-problems-tcp-is-designed-to-solve">Problems TCP is designed to solve</h2>
<p>Without TCP, applications would need to handle these problems themselves:</p>
<ul>
<li><p>Packet loss.</p>
</li>
<li><p>Out-of-order delivery.</p>
</li>
<li><p>Data Corruption.</p>
</li>
<li><p>Network Congestion</p>
</li>
<li><p>Flow control.</p>
</li>
</ul>
<hr />
<h2 id="heading-tcp-3-way-handshake-process"><strong>TCP 3-way Handshake Process</strong></h2>
<p>Communication over the internet follows the TCP/IP model. Applications like web browsers use the Application Layer, and their data is passed to the Transport Layer, where TCP and UDP work.</p>
<ul>
<li><p>TCP is widely used because it provides reliable communication.</p>
</li>
<li><p>UDP is faster but unreliable (e.g., used in DNS lookups).</p>
</li>
</ul>
<p><img src="https://media.geeksforgeeks.org/wp-content/uploads/handshake-1.png" alt="TCP 3 Way Handshaking" class="image--center mx-auto" /></p>
<ul>
<li><p><strong>Step 1 (SYN):</strong> In the first step, the client wants to establish a connection with a server, so it sends a segment with SYN(Synchronize Sequence Number) which informs the server that the client is likely to start communication and with what sequence number it starts segments with</p>
</li>
<li><p><strong>Step 2 (SYN + ACK):</strong> Server responds to the client request with SYN-ACK signal bits set. Acknowledgement(ACK) signifies the response of the segment it received and SYN signifies with what sequence number it is likely to start the segments with</p>
</li>
<li><p><strong>Step 3 (ACK):</strong> In the final part client acknowledges the response of the server and they both establish a reliable connection with which they will start the actual data transfer.</p>
</li>
</ul>
<hr />
<h2 id="heading-how-data-transfer-works-in-tcp">How data transfer works in TCP</h2>
<h3 id="heading-segmenting"><strong>Segmenting</strong></h3>
<ul>
<li><p>When an application sends data (like an email or file), TCP breaks the data into smaller chunks called segments.</p>
</li>
<li><p>Each segment has a header containing information like sequence numbers, ports, and flags.</p>
</li>
<li><p>This makes it easier to send large amounts of data over the network reliably.</p>
</li>
</ul>
<h3 id="heading-routing-via-ip"><strong>Routing via IP</strong></h3>
<ul>
<li><p>Once TCP creates segments, they are handed to IP (Internet Protocol).</p>
</li>
<li><p>IP is responsible for delivering the segments from the sender to the receiver, possibly through multiple routers.</p>
</li>
<li><p>TCP doesn’t care about the path—IP handles routing and addressing.</p>
</li>
</ul>
<h3 id="heading-reassembly-at-receiver"><strong>Reassembly at Receiver</strong></h3>
<ul>
<li><p>Segments may arrive out of order because they can take different paths through the network.</p>
</li>
<li><p>TCP at the receiver uses sequence numbers to reassemble the segments into the correct order to reconstruct the original message.</p>
</li>
</ul>
<h3 id="heading-retransmission"><strong>Retransmission</strong></h3>
<ul>
<li><p>If the sender does not receive an acknowledgment within a certain time, it resends the missing segment.</p>
</li>
<li><p>This ensures no data is lost, making TCP reliable.</p>
</li>
</ul>
<p>and lot more..</p>
<hr />
<h2 id="heading-how-tcp-ensures-reliability-order-and-correctness">How TCP Ensures Reliability, Order, and Correctness</h2>
<ul>
<li><p>Retransmission<br />  TCP <strong>retransmits</strong> the missing segment if an ACK is not received in time</p>
</li>
<li><p>Order (Sequence Numbers)<br />  Every byte has a sequence number. Receiver get Buffers out-of-order segments and reassembles data correctly.</p>
</li>
</ul>
<hr />
<h2 id="heading-how-a-tcp-connection-is-closed">How a TCP Connection Is Closed</h2>
<p>TCP connection termination is the process of closing an established TCP connection between two devices in an orderly way. It uses a four-step handshake (FIN-ACK exchange) to ensure that both sides have finished sending and receiving all data before the connection is fully closed.</p>
<h2 id="heading-types-of-tcp-connection-release"><strong>Types of TCP Connection Release</strong></h2>
<p>TCP supports two types of connection releases like most connection-oriented transport protocols: </p>
<ol>
<li><p><strong>Abrupt connection release:</strong> In an Abrupt connection release, either one TCP entity is forced to close the connection or one user closes both directions of data transfer.</p>
</li>
<li><p><strong>Graceful connection release:</strong> In the Graceful connection release, the connection is open until both parties have closed their sides of the connection.</p>
</li>
</ol>
<hr />
<p>TCP is the protocol that turns an unreliable network into a reliable communication channel by using connections, acknowledgments, retransmissions, and flow control.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Network Devices]]></title><description><![CDATA[Network Devices (or networking hardware) are the physical appliances required for communication and interaction between computers on a computer network.
When two or more computers need to communicate with each other, they form a network.But computers...]]></description><link>https://blogs.mukuldev.in/understanding-network-devices</link><guid isPermaLink="true">https://blogs.mukuldev.in/understanding-network-devices</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[networking]]></category><category><![CDATA[network devices]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 31 Jan 2026 12:30:39 GMT</pubDate><content:encoded><![CDATA[<p>Network Devices (or networking hardware) are the physical appliances required for communication and interaction between computers on a computer network.</p>
<p>When two or more computers need to communicate with each other, they form a <strong>network</strong>.<br />But computers don’t connect and talk by magic — they need <strong>network devices</strong> to help them send, receive, and manage data.</p>
<p>Network devices act like <strong>traffic controllers</strong> of a network.</p>
<hr />
<h2 id="heading-what-is-a-modem-and-how-it-connects-your-network-to-the-internet">What is a Modem and how it connects your network to the internet?</h2>
<p><strong>Modem</strong> stands for Modulator/Demodulator. The modem is a <strong>networking device</strong> that is used to connect devices connected in the network to the <strong>internet</strong>.</p>
<p>The main function of a modem is to convert the <strong>analog signals</strong> that come from telephone wire into a digital form. In digital form, these converted signals are stored in the form of 0s and 1s. The modem can perform both the task of <strong>modulation</strong> and demodulation simultaneously.</p>
<hr />
<h2 id="heading-what-is-a-router-and-how-it-directs-traffic">What is a Router and how it directs traffic?</h2>
<p>A router is a networking device that forwards data packets between different computer networks. It connects multiple packet-switched networks or subnetworks, managing traffic by directing packets to their intended IP addresses. Routers allow multiple devices to share an Internet connection efficiently.</p>
<p>Routers determine the path for a packet by examining its destination IP address and consulting the routing table, which contains information on network paths. They use a set of rules to identify the most efficient route for each packet.</p>
<ul>
<li><p><strong>Static routing:</strong> Configured manually, suitable for small or stable networks.</p>
</li>
<li><p><strong>Dynamic routing:</strong> Automatically updated based on network activity, ideal for large or changing networks.</p>
</li>
</ul>
<hr />
<h2 id="heading-switch-vs-hub-how-local-networks-actually-work">Switch vs Hub: how local networks actually work?</h2>
<h2 id="heading-hub">Hub</h2>
<p>Let’s say <strong>Host A</strong> sends data to <strong>Host C</strong>. When the hub receives this data, it doesn’t know who the actual destination is. So it simply <strong>broadcasts the data to every port</strong>, except the one it received the data from.</p>
<h2 id="heading-switch">Switch</h2>
<p>Switch is a network device which is used to enable the connection establishment and connection termination on the basis of need. <strong>Switch</strong> is operated on Data link layer. In this packet filtering is available. It is type of <strong>full duplex</strong> transmission mode and it is also called efficient bridge. </p>
<h2 id="heading-difference-between-hub-and-switch"><strong>Difference between Hub and Switch</strong></h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Hub</strong></td><td><strong>Switch</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>Hub</strong> is operated on <strong>Physical layer of OSI model</strong>.</td><td>While <strong>switch</strong> is operated on <strong>Data link layer of OSI Model</strong>.</td></tr>
<tr>
<td>Hub is a broadcast type transmission.</td><td>While switch is a Unicast, multicast and broadcast type transmission.</td></tr>
<tr>
<td>Hub have 4/12 ports.</td><td>While switch can have 24 to 48 ports.</td></tr>
<tr>
<td>In hub, there is only one collision domain.</td><td>While in switch, different ports have own collision domain.</td></tr>
<tr>
<td>Hub is a half duplex transmission mode.</td><td>While switch is a full duplex transmission mode.</td></tr>
<tr>
<td>In hub, Packet filtering is not provided.</td><td>While in switch, Packet filtering is provided.</td></tr>
<tr>
<td>Hub cannot be used as a repeater.</td><td>While switch can be used as a repeater.</td></tr>
<tr>
<td>Hub is not an intelligent device that sends message to all ports hence it is comparatively inexpensive.</td><td>While switch is an intelligent device that sends message to selected destination so it is expensive.</td></tr>
<tr>
<td>Hub is simply old type of device and is not generally used.</td><td>While switch is very sophisticated device and widely used.</td></tr>
<tr>
<td></td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-what-is-a-firewall-and-why-security-lives-here">What is a Firewall and why security lives here?</h2>
<p>A <strong>firewall</strong> is a security device (or software) that sits between your <strong>internal network</strong> and the <strong>outside world (internet)</strong> and controls what traffic is allowed to pass.</p>
<p>Every time data tries to enter or leave your network, the firewall checks it against a set of <strong>security rules</strong>.</p>
<hr />
<h2 id="heading-what-is-a-load-balancer-and-why-scalable-systems-need-it">What is a Load Balancer and why scalable systems need it?</h2>
<p>A load balancer is a networking device or software application that distributes and balances the incoming traffic among the servers to provide high availability, efficient utilization of servers and high performance.</p>
<ul>
<li><p>Ensures that no single server bears too many requests, which helps improve the performance, <strong>reliability</strong> and <strong>availability</strong> of applications.</p>
</li>
<li><p>Highly used in cloud computing domains, data centers and large-scale web applications where traffic flow needs to be managed.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769861967144/7d338f6a-dbd4-47a5-a5b7-6dec0343f8a7.webp" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-how-all-these-devices-work-together-in-a-real-world-setup">How all these devices work together in a real-world setup?</h2>
<p>In a real-world network, these devices work together in a simple pipeline. A <strong>switch</strong> connects devices within the same local network and forwards data efficiently using MAC addresses. When traffic needs to reach another network or the internet, a <strong>router</strong> forwards packets based on IP addresses, usually performing NAT (Network Address Translation). A <strong>firewall</strong> enforces security rules, allowing or blocking traffic. The <strong>modem</strong> converts digital data into signals suitable for the ISP’s network. On the server side, a <strong>load balancer</strong> receives incoming requests and distributes them across multiple backend servers to improve performance and availability. Together, they provide connectivity, security, and scalability.</p>
]]></content:encoded></item><item><title><![CDATA[Emmet for HTML]]></title><description><![CDATA[What is Emmet?
Emmet has made HTML and CSS superfast.
You have to type a expression then it converts it into a proper code.
Even if you want design a small webpage you have to type multiple line that too results in several typing mistakes.
HTML witho...]]></description><link>https://blogs.mukuldev.in/emmet-for-html</link><guid isPermaLink="true">https://blogs.mukuldev.in/emmet-for-html</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Emmet]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[CSS]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 31 Jan 2026 12:06:37 GMT</pubDate><content:encoded><![CDATA[<p><strong>What is Emmet?</strong></p>
<p>Emmet has made HTML and CSS superfast.</p>
<p>You have to type a expression then it converts it into a proper code.</p>
<p>Even if you want design a small webpage you have to type multiple line that too results in several typing mistakes.</p>
<h3 id="heading-html-without-emmet"><strong>HTML without Emmet</strong></h3>
<p>Before emmet, developers typed each and every tag by hand which was time consuming.</p>
<p>They had type opening and closing tags, also they would have to remember correct nesting, had multiple typing errors.</p>
<p><strong>Why Emmet is useful for HTML beginners?</strong></p>
<p>As given above, emmet helps to save time, increase productivity, don’t need to type repetitive tags. As a beginner they can forget proper nesting, or to close tags. Therefore, it is very useful for beginner emmet will take care of above things and beginners can focus on learning concepts.</p>
<h3 id="heading-how-emmet-works-inside-code-editors"><strong>How emmet works inside code editors?</strong></h3>
<p>Code editors that support Emmet are:</p>
<p>1.VS Code (Visual Studio code)- Emmet is built-in by default</p>
<p>2.Sublime Text - It supports Emmet through plugin (you have install Emmet package).</p>
<p>3.Atom - Emmet is built-in by default</p>
<p>4.Notepad++ (Emmet via plugin)</p>
<p>As we have seen in the beginning of this blog, you do not need to type entire code, you can use shortcuts. When you type an Emmet abbreviation, press <strong>Tab or Enter, emmet converts it into HTML code.</strong></p>
<h3 id="heading-basic-emmet-syntax-and-abbreviations"><strong>Basic Emmet Syntax and abbreviations:</strong></h3>
<p>When you type p emmet converts it to &lt;p&gt;&lt;/p&gt;</p>
<pre><code class="lang-basic">&lt;p&gt;&lt;/p&gt;
</code></pre>
<p>When you type div</p>
<pre><code class="lang-basic">&lt;div&gt;&lt;/div&gt;
</code></pre>
<p>Observe the below table</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Symbol</td><td>Meaning</td></tr>
</thead>
<tbody>
<tr>
<td>\&gt;</td><td>Child Element</td></tr>
<tr>
<td>+</td><td>Sibling Element</td></tr>
<tr>
<td>*</td><td>Multiple Elements</td></tr>
<tr>
<td>.</td><td>Class</td></tr>
<tr>
<td>#</td><td>ID</td></tr>
</tbody>
</table>
</div><p>When you type div&gt;p</p>
<pre><code class="lang-basic">&lt;div&gt;
  &lt;p&gt;&lt;/p&gt;
&lt;/div&gt;
</code></pre>
<p>Type h1+p</p>
<pre><code class="lang-xml"><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">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>To repeat elements</p>
<p>li*4</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>
<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>To add a class</p>
<p>type <a target="_blank" href="http://div.box">div.box</a></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">"box"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>To add an id</p>
<p>type section#main</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">"main"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>
</code></pre>
<p>To add attributes</p>
<p>img[src=”logo.png” alt=”logo”]</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"logo.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"logo"</span>&gt;</span>
</code></pre>
<p>Nesting in Emmet</p>
<p>let us type, div&gt;ul&gt;li*2</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">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">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>When you use ‘! ‘ in html file, you get whole template.</p>
<p><img src="https://kinsta.com/wp-content/uploads/2021/11/Untitled-54.png" alt="The Best Way to Learn HTML for Free (and Why You Should)" /></p>
<h3 id="heading-conclusion"><strong>Conclusion</strong></h3>
<p>Therefore, we can say that Emmet saves time, instead of typing tags again and again we can use emmet abbreviations. It makes HTML easy for beginners. It improves productivity.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding HTML Tags and Elements]]></title><description><![CDATA[What HTML is ?
HTML stand for Hyper Text Markup Language.
HTML (HyperText Markup Language) is the standard language used to create and structure web pages. It uses tags and elements to define headings, paragraphs, images, links, and other components ...]]></description><link>https://blogs.mukuldev.in/understanding-html-tags-and-elements</link><guid isPermaLink="true">https://blogs.mukuldev.in/understanding-html-tags-and-elements</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[HTML5]]></category><dc:creator><![CDATA[Mukul Sharma]]></dc:creator><pubDate>Sat, 31 Jan 2026 10:51:43 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-what-html-is"><strong>What HTML is ?</strong></h2>
<p>HTML stand for <strong>Hyper Text Markup Language</strong>.</p>
<p>HTML (HyperText Markup Language) is the standard language used to create and structure web pages. It uses tags and elements to define headings, paragraphs, images, links, and other components that browsers display on the screen.</p>
<p>HTML is platform-independent and runs on all browsers.</p>
<hr />
<h2 id="heading-why-we-use-html"><strong>Why we use HTML</strong></h2>
<p>HTML is used to create structure of a web page.</p>
<p>Learning <strong>HTML</strong> is essential because it forms the foundation of every website and is the first step toward becoming a web developer.</p>
<p>CSS make website look good<br />JavaScript make website interactive<br />But <strong>HTML is the skeleton of the web page</strong>.</p>
<hr />
<h2 id="heading-what-an-html-tag-is"><strong>What an HTML tag is</strong></h2>
<p>HTML tag is a special keyword written inside angle brackets <code>&lt; &gt;</code>.</p>
<p>Tag tell browser what kind of content it is.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">&lt;p&gt;
&lt;h1&gt;
&lt;img&gt;
</code></pre>
<p>Each tag have its own work.</p>
<p><code>&lt;p&gt;</code> tell this is a paragraph<br /><code>&lt;h1&gt;</code> tell this is a heading<br /><code>&lt;img&gt;</code> tell this is an image</p>
<hr />
<h2 id="heading-opening-tag-closing-tag-and-content"><strong>Opening tag, closing tag, and content</strong></h2>
<p>Most HTML tags have <strong>opening tag</strong> and <strong>closing tag</strong>.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">&lt;p&gt;Hello World&lt;/p&gt;
</code></pre>
<p><code>&lt;p&gt;</code> → opening tag<br /><code>&lt;/p&gt;</code> → closing tag<br /><code>Hello World</code> → content</p>
<hr />
<h2 id="heading-what-an-html-element-means"><strong>What an HTML element means</strong></h2>
<p>HTML element is <strong>full structure together</strong>.</p>
<p>Opening tag + content + closing tag = HTML element</p>
<p>Example:</p>
<pre><code class="lang-plaintext">&lt;h1&gt;Welcome&lt;/h1&gt;
</code></pre>
<p>This whole line is one HTML element.</p>
<p>Element tell browser:</p>
<ul>
<li><p>what type of content</p>
</li>
<li><p>and what content it is</p>
</li>
</ul>
<hr />
<h2 id="heading-self-closing-void-elements"><strong>Self-closing (void) elements</strong></h2>
<p>Some HTML tags don’t have closing tag.</p>
<p>These are called <strong>self-closing</strong> or <strong>void elements</strong>.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">&lt;img&gt;
&lt;br&gt;
&lt;input&gt;
</code></pre>
<p>These tags don’t wrap content.<br />They just perform one action.</p>
<p><code>&lt;img&gt;</code> show image<br /><code>&lt;br&gt;</code> break line<br /><code>&lt;input&gt;</code> take input from user</p>
<hr />
<h2 id="heading-block-level-vs-inline-elements"><strong>Block-level vs inline elements</strong></h2>
<h3 id="heading-block-level-elements"><strong>Block-level elements</strong></h3>
<p>Block elements always start from new line.<br />They take full width of page.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">&lt;div&gt;
&lt;p&gt;
&lt;h1&gt;
</code></pre>
<p>If you use block element, next content go to next line.</p>
<hr />
<h3 id="heading-inline-elements"><strong>Inline elements</strong></h3>
<p>Inline elements stay in same line.<br />They take only required space.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">&lt;span&gt;
&lt;a&gt;
&lt;strong&gt;
</code></pre>
<p>Inline elements are mostly used inside block elements.</p>
<hr />
<h2 id="heading-commonly-used-html-tags"><strong>Commonly used HTML tags</strong></h2>
<p>Some HTML tags are used in almost every website.</p>
<h3 id="heading-structure-tags"><strong>Structure tags</strong></h3>
<pre><code class="lang-plaintext">&lt;html&gt;
&lt;head&gt;
&lt;body&gt;
</code></pre>
<h3 id="heading-text-tags"><strong>Text tags</strong></h3>
<pre><code class="lang-plaintext">&lt;h1&gt; to &lt;h6&gt;
&lt;p&gt;
&lt;span&gt;
</code></pre>
<h3 id="heading-media-and-link"><strong>Media and link</strong></h3>
<pre><code class="lang-plaintext">&lt;img&gt;
&lt;a&gt;
</code></pre>
<h3 id="heading-form-tags"><strong>Form tags</strong></h3>
<pre><code class="lang-plaintext">&lt;input&gt;
&lt;button&gt;
</code></pre>
<p>These tags help browser understand <strong>what content is text, image, link, or input</strong>.</p>
<hr />
<h2 id="heading-in-the-conclusion"><strong>In the conclusion</strong></h2>
<p>HTML is the foundation of web development.</p>
<p>It give structure to website.<br />It tell browser how to display content.</p>
<p>Without HTML, web page can’t exist.</p>
<p>HTML is first step for every web developer.</p>
]]></content:encoded></item></channel></rss>