<?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[Birendra K]]></title><description><![CDATA[Chaicode cohort2026]]></description><link>https://birendra.site</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 16:07:12 GMT</lastBuildDate><atom:link href="https://birendra.site/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Arrow Functions in JavaScript: A Simpler Way to Write Functions]]></title><description><![CDATA[Modern JavaScript introduced arrow functions in ECMAScript 2015 to reduce boilerplate and make functions shorter and easier to read. Arrow functions use the => syntax and provide a concise way to writ]]></description><link>https://birendra.site/arrow-functions-in-javascript-a-simpler-way-to-write-functions</link><guid isPermaLink="true">https://birendra.site/arrow-functions-in-javascript-a-simpler-way-to-write-functions</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[#arrowfunction]]></category><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Fri, 13 Mar 2026 10:06:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69512612b0b404270034c5bf/6817df5d-03eb-474f-93d0-9b0313e1ee4b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Modern <strong>JavaScript</strong> introduced <strong>arrow functions</strong> in <strong>ECMAScript 2015</strong> to reduce boilerplate and make functions shorter and easier to read. Arrow functions use the <code>=&gt;</code> syntax and provide a concise way to write function expressions.</p>
<p>This article explains arrow functions step-by-step with simple examples.</p>
<h2>1. What Arrow Functions Are</h2>
<p>An <strong>arrow function</strong> is a shorter way to write a function expression in JavaScript using the <code>=&gt;</code> arrow syntax.</p>
<p>It performs the same job as a normal function but with <strong>less code and cleaner syntax</strong>.</p>
<h3>Example</h3>
<p>Normal function:</p>
<pre><code class="language-javascript">function greet(name) {
  return "Hello " + name;
}
</code></pre>
<p>Arrow function:</p>
<pre><code class="language-javascript">const greet = (name) =&gt; {
  return "Hello " + name;
};
</code></pre>
<p>Both functions do the same thing — return a greeting message.</p>
<p>Arrow functions are commonly used in:</p>
<ul>
<li><p>array methods (<code>map</code>, <code>filter</code>, <code>reduce</code>)</p>
</li>
<li><p>callbacks</p>
</li>
<li><p>modern JavaScript codebases</p>
</li>
</ul>
<hr />
<h2>2. How Arrow Functions Reduce Boilerplate</h2>
<p>Traditional functions require several keywords:</p>
<ul>
<li><p><code>function</code></p>
</li>
<li><p><code>return</code></p>
</li>
<li><p>curly braces <code>{}</code></p>
</li>
</ul>
<p>Arrow functions remove unnecessary syntax.</p>
<h3>Example Transformation</h3>
<p>Normal Function</p>
<pre><code class="language-javascript">function add(a, b) {
  return a + b;
}
</code></pre>
<p>Arrow Function</p>
<pre><code class="language-javascript">const add = (a, b) =&gt; a + b;
</code></pre>
<p>Here we removed:</p>
<ul>
<li><p><code>function</code></p>
</li>
<li><p><code>return</code></p>
</li>
<li><p><code>{ }</code></p>
</li>
</ul>
<p>This makes the code <strong>shorter and easier to read</strong>.</p>
<hr />
<h2>3. Basic Arrow Function Syntax</h2>
<p>General syntax:</p>
<pre><code class="language-javascript">const functionName = (parameters) =&gt; {
  // function body
  return value;
};
</code></pre>
<p>Example:</p>
<pre><code class="language-javascript">const multiply = (a, b) =&gt; {
  return a * b;
};

console.log(multiply(4, 3)); // 12
</code></pre>
<h3>Syntax Breakdown</h3>
<pre><code class="language-javascript">(parameters) =&gt; { function body }
</code></pre>
<p>Diagram idea:</p>
<pre><code class="language-plaintext">(parameters)   =&gt;   { code }
     │          │        │
     │          │        └ function body
     │          └ arrow syntax
     └ function parameters
</code></pre>
<hr />
<h2>4. Arrow Functions with One Parameter</h2>
<p>If the function has <strong>only one parameter</strong>, parentheses are optional.</p>
<p>Normal form:</p>
<pre><code class="language-javascript">const square = (num) =&gt; {
  return num * num;
};
</code></pre>
<p>Shorter version:</p>
<pre><code class="language-javascript">const square = num =&gt; num * num;
</code></pre>
<p>Example:</p>
<pre><code class="language-javascript">console.log(square(5)); // 25
</code></pre>
<hr />
<h2>5. Arrow Functions with Multiple Parameters</h2>
<p>When a function has <strong>two or more parameters</strong>, parentheses are required.</p>
<p>Example:</p>
<pre><code class="language-javascript">const add = (a, b) =&gt; a + b;

console.log(add(5, 7)); // 12
</code></pre>
<p>Another example:</p>
<pre><code class="language-javascript">const greet = (name, age) =&gt; {
  return `Hello \({name}, age \){age}`;
};
</code></pre>
<hr />
<h2>6. Implicit Return vs Explicit Return</h2>
<p>Arrow functions support <strong>two types of return behavior</strong>.</p>
<hr />
<h2>Explicit Return</h2>
<p>When using curly braces <code>{}</code>, you must use <code>return</code>.</p>
<pre><code class="language-javascript">const multiply = (a, b) =&gt; {
  return a * b;
};
</code></pre>
<hr />
<h2>Implicit Return</h2>
<p>If the function contains <strong>only one expression</strong>, you can remove <code>{}</code> and <code>return</code>.</p>
<pre><code class="language-plaintext">const multiply = (a, b) =&gt; a * b;
</code></pre>
<p>Example:</p>
<pre><code class="language-plaintext">const greet = name =&gt; "Hello " + name;
</code></pre>
<p>Arrow functions automatically return the expression value in this case.</p>
<hr />
<h2>7. Basic Difference Between Arrow Function and Normal Function</h2>
<table>
<thead>
<tr>
<th>Feature</th>
<th>Normal Function</th>
<th>Arrow Function</th>
</tr>
</thead>
<tbody><tr>
<td>Syntax</td>
<td>Uses <code>function</code> keyword</td>
<td>Uses <code>=&gt;</code></td>
</tr>
<tr>
<td>Code length</td>
<td>Longer</td>
<td>Shorter</td>
</tr>
<tr>
<td>Return</td>
<td>Needs <code>return</code></td>
<td>Can use implicit return</td>
</tr>
<tr>
<td>Usage</td>
<td>Traditional style</td>
<td>Modern JavaScript</td>
</tr>
<tr>
<td>Definition</td>
<td>Can be a function declaration</td>
<td>Always function expression</td>
</tr>
</tbody></table>
<p>Example comparison:</p>
<p>Normal function:</p>
<pre><code class="language-javascript">function square(num) {
  return num * num;
}
</code></pre>
<p>Arrow function:</p>
<pre><code class="language-javascript">const square = num =&gt; num * num;
</code></pre>
<hr />
<h2>8. Using Arrow Functions with <code>map()</code></h2>
<p>Arrow functions are very common in array operations.</p>
<p>Example:</p>
<pre><code class="language-javascript">const numbers = [1, 2, 3, 4];

const squares = numbers.map(num =&gt; num * num);

console.log(squares);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">[1, 4, 9, 16]
</code></pre>
<p>This makes functional programming patterns <strong>much cleaner</strong>.</p>
<hr />
<h2>9. Practice Assignment</h2>
<p>Try these exercises.</p>
<h3>1️⃣ Convert Normal Function to Arrow Function</h3>
<p>Normal function:</p>
<pre><code class="language-javascript">function square(num) {
  return num * num;
}
</code></pre>
<p>Rewrite using arrow function.</p>
<hr />
<h3>2️⃣ Even or Odd Checker</h3>
<p>Create an arrow function that checks whether a number is even or odd.</p>
<p>Example:</p>
<pre><code class="language-javascript">const isEven = num =&gt; num % 2 === 0;
</code></pre>
<hr />
<h3>3️⃣ Use Arrow Function in <code>map()</code></h3>
<pre><code class="language-javascript">const numbers = [1,2,3,4,5];

const doubled = numbers.map(num =&gt; num * 2);

console.log(doubled);
</code></pre>
<hr />
<h2>Final Thoughts</h2>
<p>Arrow functions are now a <strong>core part of modern JavaScript</strong> because they:</p>
<ul>
<li><p>Reduce boilerplate code</p>
</li>
<li><p>improve readability</p>
</li>
<li><p>work perfectly with array methods and callbacks</p>
</li>
</ul>
<p>For beginners, focus on:</p>
<ul>
<li><p>simple syntax</p>
</li>
<li><p>implicit return</p>
</li>
<li><p>converting normal functions into arrow functions</p>
</li>
</ul>
<p>Advanced topics like <code>this</code> Behavior can be explored later.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Variables and Data Types in JavaScript]]></title><description><![CDATA[Variables — Containers for Storing Data
A variable is a container where you can store data. In JavaScript, there are 3 ways to declare variables:
• var — Old method, function-scoped, can be overwritte]]></description><link>https://birendra.site/understanding-variables-and-data-types-in-javascript</link><guid isPermaLink="true">https://birendra.site/understanding-variables-and-data-types-in-javascript</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sun, 08 Mar 2026 07:32:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69512612b0b404270034c5bf/74c75a37-1bf4-4d29-93e3-15f1c99b1c0c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Variables — Containers for Storing Data</h2>
<p>A variable is a container where you can store data. In JavaScript, there are 3 ways to declare variables:</p>
<p>• var — Old method, function-scoped, can be overwritten anytime</p>
<p>• let — Modern method, block-scoped, value can be changed</p>
<p>• const — Block-scoped, value CANNOT be changed after assignment</p>
<p>Adds element at beginning.</p>
<pre><code class="language-javascript">var score = 10; // old way
let name = "Shaaz"; // modern way
const pi = 3.14; // constant, never changes
</code></pre>
<p><strong>Tip:</strong> <em>Use 'const' by default. Use 'let' only when the value needs to change. Avoid 'var' in modern code</em>.</p>
<p><strong>✅Remember:</strong> <em>var is function-scoped. let and const are block-scoped. This difference matters inside loops and if-blocks</em>.</p>
<h2>Data Types</h2>
<p>JavaScript has 7 main data types. Knowing these is very important for interviews:</p>
<p><strong>1. Number — for all numeric values</strong></p>
<pre><code class="language-javascript">let age = 25;
let price = 99.99;
</code></pre>
<p><strong>2. String — for text</strong></p>
<pre><code class="language-javascript">let name = "Shaaz";
let city = 'Delhi';
</code></pre>
<p><strong>3. Boolean — true or false only</strong></p>
<pre><code class="language-javascript">let isLoggedIn = true;
let isAdmin = false;
</code></pre>
<p><strong>4. Null — intentionally empty</strong></p>
<p>Use null when you want to say 'this variable exists but has no value on purpose'.</p>
<pre><code class="language-javascript">let emptyValue = null;
</code></pre>
<p><strong>5. Undefined — not assigned yet</strong></p>
<p>When you declare a variable but do not give it a value, it becomes undefined automatically.</p>
<pre><code class="language-javascript">let noValue;
console.log(noValue); // Output: undefined
</code></pre>
<p><strong>6. Object — key-value pairs</strong></p>
<p>Objects store multiple related values together.</p>
<pre><code class="language-javascript">let person = { name: "Shaaz", age: 25, city: "Delhi" };
console.log(person.name); // Output: Shaaz
</code></pre>
<p><strong>7. Array — ordered list of values</strong></p>
<p>Arrays store multiple values in a sequence. Each value has an index starting from 0.</p>
<pre><code class="language-javascript">Adds element at beginning.

const nums = [2, 3];

nums.unshift(1);

console.log(nums);
// [1, 2, 3]
</code></pre>
<p><strong>✅Remember:</strong> <em>null means empty on purpose. undefined means not yet assigned. They are NOT the same!</em></p>
<p><strong>🟢 Tip:</strong> <em>Use typeof to check the data type of any</em> <code>variable: console.log(typeof 'hello'); // Output: string</code></p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Array Methods You Must Know]]></title><description><![CDATA[Arrays are one of the most important data structures in JavaScript. Almost every real-world application — from API data handling to UI rendering — depends on array operations.
In this article, you’ll ]]></description><link>https://birendra.site/javascript-array-methods-you-must-know</link><guid isPermaLink="true">https://birendra.site/javascript-array-methods-you-must-know</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Javascript Methods]]></category><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Mon, 02 Mar 2026 08:15:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69512612b0b404270034c5bf/79dccb56-6d89-4196-8569-ca1a1c7eff5a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Arrays are one of the most important data structures in JavaScript. Almost every real-world application — from API data handling to UI rendering — depends on array operations.</p>
<p>In this article, you’ll learn the <strong>most essential JavaScript array methods</strong> with simple explanations, practical examples, and easy memory tricks so you never forget them.</p>
<h2><strong>What is Array in JS?</strong></h2>
<p>The Array object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name, and has members for performing common array operations.</p>
<h2><strong>Declaring arrays</strong></h2>
<p>We can declare arrays in two different ways.</p>
<h3><strong>Using new Array</strong></h3>
<p>With new Array, we could specify the elements we want to exist within the array, like this:</p>
<pre><code class="language-javascript">const fruits = new Array('Apple', 'Banana');
console.log(fruits.length);
</code></pre>
<h3><strong>Array literal notation</strong></h3>
<p>Declaring with an array literal, we specify the values that the array will have. If we don’t declare any values, the array will be empty.</p>
<pre><code class="language-javascript">// 'fruits' array created using array literal notation.
const fruits = ['Apple', 'Banana'];
console.log(fruits.length);
</code></pre>
<h3><strong>Javascript Array Methods</strong></h3>
<p>Here is a list of the methods of the Array object along with their description.</p>
<ol>
<li><h2><strong>forEach</strong></h2>
</li>
</ol>
<p>The forEach() method executes a provided function once for each array element.</p>
<p>forEach() calls a provided callbackFn function once for each element in an array in ascending index order. It is not invoked for index properties that have been deleted or are uninitialized.</p>
<pre><code class="language-javascript">array.forEach(callback[, thisObject]);
</code></pre>
<pre><code class="language-javascript">const array1 = ['a', 'b', 'c'];

array1.forEach(element =&gt; console.log(element));

// expected output: "a"
// expected output: "b"
// expected output: "c"
</code></pre>
<h2><strong>2 .map</strong></h2>
<p>The Array.map() method allows you to iterate over an array and modify its elements using a callback function. The callback function will then be executed on each of the array's elements.</p>
<pre><code class="language-javascript">array.map(callback[, thisObject]);
</code></pre>
<pre><code class="language-javascript">let arr = [3, 4, 5, 6];

let modifiedArr = arr.map(function(element){
    return element *3;
});

console.log(modifiedArr); // [9, 12, 15, 18]
</code></pre>
<p>The <a href="http://Array.map">Array.map</a>() method is commonly used to apply some changes to the elements, whether multiplying by a specific number as in the code above, or doing any other operations that you might require for your application.</p>
<h2><strong>3 .concat</strong></h2>
<p>In JavaScript, concat() is a string method that is used to concatenate strings together. The concat() method appends one or more string values to the calling string and then returns the concatenated result as a new string. Because the concat() method is a method of the String object, it must be invoked through a particular instance of the String class.</p>
<pre><code class="language-javascript">array.concat(value1, value2, ..., valueN);
</code></pre>
<pre><code class="language-javascript">const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = array1.concat(array2);

console.log(array3);
// expected output: Array ["a", "b", "c", "d", "e", "f"]
</code></pre>
<h2><strong>4 .push</strong></h2>
<p>The JavaScript array push() method appends the given element(s) in the last of the array and returns the length of the new array.<br />When you want to add an element to the end of your array, use push().</p>
<pre><code class="language-javascript">array.push(element1, ..., elementN);
</code></pre>
<pre><code class="language-javascript">const countries = ["Nigeria", "Ghana", "Rwanda"];

countries.push("Kenya");

console.log(countries); // ["Nigeria","Ghana","Rwanda","Kenya"]
</code></pre>
<h2><strong>5 .pop</strong></h2>
<p>The pop() method removes the last element from an array and returns that value to the caller. If you call pop() on an empty array, it returns undefined.</p>
<p>Array.prototype.shift() has similar behaviour to pop(), but applied to the first element in an array.</p>
<pre><code class="language-javascript">array.pop();
</code></pre>
<pre><code class="language-javascript">const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato'];

console.log(plants.pop());
// expected output: "tomato"

console.log(plants);
// expected output: Array ["broccoli", "cauliflower", "cabbage", "kale"]
</code></pre>
<h2><strong>6 .splice</strong></h2>
<p>The splice() method is a general-purpose method for changing the contents of an array by removing, replacing, or adding elements in specified positions of the array. This section will cover how to use this method to add an element to a specific location.</p>
<pre><code class="language-javascript">array.splice(index, howMany, [element1][, ..., elementN]);
</code></pre>
<pre><code class="language-javascript">const fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.splice(2, 0, "Lemon", "Kiwi"); //Banana,Orange,Lemon,Kiwi,Apple,Mango
</code></pre>
<h2><strong>7 .slice</strong></h2>
<p>The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.</p>
<pre><code class="language-javascript">array.slice( begin [,end] );
</code></pre>
<pre><code class="language-javascript">const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];

console.log(animals.slice(2));
// expected output: Array ["camel", "duck", "elephant"]

console.log(animals.slice(2, 4));
// expected output: Array ["camel", "duck"]
</code></pre>
<h2><strong>8 .shift</strong></h2>
<p>shift() is a built-in JavaScript function that removes the first element from an array. The shift() function directly modifies the JavaScript array with which you are working. shift() returns the item you have removed from the array.</p>
<p>The shift() function removes the item at index position 0 and shifts the values at future index numbers down by one.</p>
<pre><code class="language-javascript">array.shift();
</code></pre>
<pre><code class="language-javascript">const array1 = [1, 2, 3];

const firstElement = array1.shift();

console.log(array1);
// expected output: Array [2, 3]

console.log(firstElement);
// expected output: 1
</code></pre>
<h2><strong>9 .unshift</strong></h2>
<p>The unshift() method inserts the given values to the beginning of an array-like object.</p>
<p>Array.prototype.push() has similar behaviour to unshift(), but applied to the end of an array.</p>
<pre><code class="language-javascript">array.unshift( element1, ..., elementN );
</code></pre>
<pre><code class="language-javascript">const array1 = [1, 2, 3];

console.log(array1.unshift(4, 5));
// expected output: 5

console.log(array1);
// expected output: Array [4, 5, 1, 2, 3]
</code></pre>
<h2><strong>10 .join</strong></h2>
<p>JavaScript array join() is a built-in method that creates and returns the new string by concatenating all of the elements of the array. The join() method joins the array’s items into a string and returns that string. The specified separator will separate the array of elements. The default separator is a comma (,).</p>
<pre><code class="language-javascript">array.join(separator);
</code></pre>
<pre><code class="language-javascript">const elements = ['Fire', 'Air', 'Water'];

console.log(elements.join());
// expected output: "Fire,Air,Water"

console.log(elements.join(''));
// expected output: "FireAirWater"

console.log(elements.join('-'));
// expected output: "Fire-Air-Water"
</code></pre>
<h2><strong>11 .every</strong></h2>
<p>The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.</p>
<pre><code class="language-javascript">array.every(callback[, thisObject]);
</code></pre>
<pre><code class="language-javascript">const isBelowThreshold = (currentValue) =&gt; currentValue &lt; 40;

const array1 = [1, 30, 39, 29, 10, 13];

console.log(array1.every(isBelowThreshold));
// expected output: true
</code></pre>
<h2><strong>12 .filter</strong></h2>
<p>The filter() method creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.</p>
<pre><code class="language-javascript">array.filter(callback[, thisObject]);
</code></pre>
<pre><code class="language-javascript">const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word =&gt; word.length &gt; 6);

console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
</code></pre>
<h2><strong>13 .indexOf</strong></h2>
<p>The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.</p>
<pre><code class="language-javascript">array.indexOf(searchElement[, fromIndex]);
</code></pre>
<pre><code class="language-javascript">const beasts = ['ant', 'bison', 'camel', 'duck', 'bison'];

console.log(beasts.indexOf('bison'));
// expected output: 1

// start from index 2
console.log(beasts.indexOf('bison', 2));
// expected output: 4

console.log(beasts.indexOf('giraffe'));
// expected output: -1
</code></pre>
<h2><strong>14 .reduce</strong></h2>
<p>The reduce() method executes a user-supplied "reducer" callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.</p>
<pre><code class="language-javascript">array.reduce(callback[, initialValue]);
</code></pre>
<pre><code class="language-javascript">const array1 = [1, 2, 3, 4];

// 0 + 1 + 2 + 3 + 4
const initialValue = 0;
const sumWithInitial = array1.reduce(
  (previousValue, currentValue) =&gt; previousValue + currentValue,
  initialValue
);

console.log(sumWithInitial)
</code></pre>
<h2><strong>15 .reverse</strong></h2>
<p>The reverse() method reverses an array in place and returns the reference to the same array, the first array element now becoming the last, and the last array element becoming the first. In other words, elements order in the array will be turned towards the direction opposite to that previously stated.</p>
<pre><code class="language-javascript">array.reverse();
</code></pre>
<pre><code class="language-javascript">const array1 = ['one', 'two', 'three'];
console.log('array1:', array1);
// expected output: "array1:" Array ["one", "two", "three"]

const reversed = array1.reverse();
console.log('reversed:', reversed);
// expected output: "reversed:" Array ["three", "two", "one"]

// Careful: reverse is destructive -- it changes the original array.
console.log('array1:', array1);
// expected output: "array1:" Array ["three", "two", "one"]
</code></pre>
<h2><strong>16 .sort</strong></h2>
<p>The sort() method sorts the elements of an array in place and returns a reference to the same array, now sorted. The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code unit values.</p>
<pre><code class="language-javascript">array.sort( compareFunction );
</code></pre>
<pre><code class="language-javascript">const months = ['March', 'Jan', 'Feb', 'Dec'];
months.sort();
console.log(months);
// expected output: Array ["Dec", "Feb", "Jan", "March"]

const array1 = [1, 30, 4, 21, 100000];
array1.sort();
console.log(array1);
// expected output: Array [1, 100000, 21, 30, 4]
</code></pre>
<h2><strong>17 .toString</strong></h2>
<p>The toString() method returns a string representing the object.</p>
<pre><code class="language-javascript">array.toString();
</code></pre>
<pre><code class="language-javascript">function Dog(name) {
  this.name = name;
}

const dog1 = new Dog('Gabby');

Dog.prototype.toString = function dogToString() {
  return `${this.name}`;
};

console.log(dog1.toString());
// expected output: "Gabby"
</code></pre>
<h2><strong>18 .at</strong></h2>
<p>The at() method takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.</p>
<pre><code class="language-javascript">array.at(index)
</code></pre>
<pre><code class="language-javascript">const array1 = [5, 12, 8, 130, 44];

let index = 2;

console.log(`Using an index of \({index} the item returned is \){array1.at(index)}`);
// expected output: "Using an index of 2 the item returned is 8"

index = -2;

console.log(`Using an index of \({index} item returned is \){array1.at(index)}`);
// expected output: "Using an index of -2 item returned is 130"
</code></pre>
<h2><strong>19 .find</strong></h2>
<p>The find() method returns the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, undefined is returned.</p>
<pre><code class="language-javascript">array.find(function(currentValue, index, arr),thisValue)
</code></pre>
<pre><code class="language-javascript">const array1 = [5, 12, 8, 130, 44];

const found = array1.find(element =&gt; element &gt; 10);

console.log(found);
// expected output: 12
</code></pre>
<h2><strong>20 .some</strong></h2>
<p>The some() method tests whether at least one element in the array passes the test implemented by the provided function. It returns true if, in the array, it finds an element for which the provided function returns true; otherwise it returns false. It doesn't modify the array.</p>
<pre><code class="language-javascript">array.some(callback[, thisObject]);
</code></pre>
<pre><code class="language-javascript">const array = [1, 2, 3, 4, 5];

// checks whether an element is even
const even = (element) =&gt; element % 2 === 0;

console.log(array.some(even));
// expected output: true
</code></pre>
]]></content:encoded></item><item><title><![CDATA[CSS Selectors 101: Targeting Elements with Precision]]></title><description><![CDATA[Why CSS Selectors Are Needed
CSS selectors let you choose which HTML elements to style. Without selectors, you couldn’t tell the browser which elements should get specific colors, fonts, or layouts. They act like addresses that point to elements in y...]]></description><link>https://birendra.site/css-selectors-101-targeting-elements-with-precision</link><guid isPermaLink="true">https://birendra.site/css-selectors-101-targeting-elements-with-precision</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sat, 31 Jan 2026 12:25:35 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-why-css-selectors-are-needed">Why CSS Selectors Are Needed</h2>
<p>CSS <strong>selectors</strong> let you <strong>choose which HTML elements to style</strong>. Without selectors, you couldn’t tell the browser which elements should get specific colors, fonts, or layouts. They act like <strong>addresses</strong> that point to elements in your HTML so styles can be applied where you want them.</p>
<p>Think of selectors like addressing people in a room:</p>
<ul>
<li><p><em>Everyone wearing a red shirt</em> gets style A</p>
</li>
<li><p><em>Only the person named Alex</em> gets style B</p>
</li>
<li><p><em>All paragraphs inside a section</em> get style C</p>
</li>
</ul>
<hr />
<h2 id="heading-basic-css-selectors">Basic CSS Selectors</h2>
<h3 id="heading-1-element-selector">1. <strong>Element Selector</strong></h3>
<p>Targets <strong>all instances of a specific HTML tag</strong>.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: blue;
}
</code></pre>
<p>This selects every <code>&lt;p&gt;</code> on the page.</p>
<hr />
<h3 id="heading-2-class-selector">2. <strong>Class Selector</strong></h3>
<p>Targets elements with a <strong>specific class</strong>.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.button</span> {
  <span class="hljs-attribute">background-color</span>: green;
}
</code></pre>
<p>The dot (<code>.</code>) before a name selects any element with that class. You can reuse it on many elements.</p>
<hr />
<h3 id="heading-3-id-selector">3. <strong>ID Selector</strong></h3>
<p>Targets a <strong>single specific element</strong> that has an ID.</p>
<pre><code class="lang-css"><span class="hljs-selector-id">#main-header</span> {
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">32px</span>;
}
</code></pre>
<p>The hash (<code>#</code>) selects the element with that ID — IDs should be unique in a page.</p>
<hr />
<h2 id="heading-group-and-descendant-selectors">Group and Descendant Selectors</h2>
<h3 id="heading-group-selectors"><strong>Group Selectors</strong></h3>
<p>Apply the <strong>same style to multiple selectors</strong> separated by commas.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">h1</span>, <span class="hljs-selector-tag">h2</span>, <span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: purple;
}
</code></pre>
<p>This applies purple text to <strong>all</strong> matching elements.</p>
<hr />
<h3 id="heading-descendant-selectors"><strong>Descendant Selectors</strong></h3>
<p>Select elements that are <strong>inside another element</strong> — at any depth.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">div</span> <span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: red;
}
</code></pre>
<p>Every <code>&lt;p&gt;</code> that’s inside a <code>&lt;div&gt;</code> gets red text.</p>
<p>This is like saying <em>“apply this style to all paragraphs inside a container.”</em></p>
<hr />
<h2 id="heading-very-basic-selector-priority-high-level">Very Basic Selector Priority (High Level)</h2>
<p>When more than one rule could apply to the same element, CSS uses <strong>specificity</strong> to decide which one wins:</p>
<ol>
<li><p><strong>Element selectors</strong> (lowest priority)</p>
</li>
<li><p><strong>Class selectors</strong></p>
</li>
<li><p><strong>ID selectors</strong> (higher priority)</p>
</li>
<li><p>Inline styles (highest)</p>
</li>
</ol>
<p>For example:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> { <span class="hljs-attribute">color</span>: red; }
<span class="hljs-selector-class">.text</span> { <span class="hljs-attribute">color</span>: green; }
<span class="hljs-selector-id">#main</span> { <span class="hljs-attribute">color</span>: blue; }
</code></pre>
<p>If a paragraph has both class <code>text</code> and ID <code>main</code>, the blue rule wins because ID selectors have greater specificity than class or element selectors.</p>
<hr />
<h2 id="heading-tips-for-beginners">Tips for Beginners</h2>
<ul>
<li><p>Think of selectors as <strong>ways to point to elements</strong> in your HTML.</p>
</li>
<li><p>Start simple: element → class → ID.</p>
</li>
<li><p>Group selectors help keep styles DRY (Don’t Repeat Yourself).</p>
</li>
<li><p>Descendant selectors let you style based on <strong>HTML structure</strong>.</p>
</li>
</ul>
<p>Selectors are the <strong>foundation of CSS</strong> — mastering them helps you style pages with precision.</p>
]]></content:encoded></item><item><title><![CDATA[How a Browser Works: A Beginner-Friendly Guide to Browser Internals]]></title><description><![CDATA[What a Browser Really Is
A web browser is software that fetches content from the internet and displays it to you as interactive web pages. It does much more than just open links — it processes, parses, layouts, and renders content like HTML, CSS, and...]]></description><link>https://birendra.site/how-a-browser-works-a-beginner-friendly-guide-to-browser-internals</link><guid isPermaLink="true">https://birendra.site/how-a-browser-works-a-beginner-friendly-guide-to-browser-internals</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sat, 31 Jan 2026 08:17:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769847403428/4ea8b018-042d-46fd-ba11-4c437d9872c8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-a-browser-really-is">What a Browser Really Is</h2>
<p>A <strong>web browser</strong> is software that <strong>fetches content from the internet and displays it to you</strong> as interactive web pages. It does much more than just open links — it <em>processes</em>, <em>parses</em>, <em>layouts</em>, and <em>renders</em> content like HTML, CSS, and JavaScript to show complete pages. As such, a browser acts as an <strong>HTTP client or user agent</strong> that requests and processes data from servers.</p>
<p>Behind the scenes, a browser is a collection of coordinated components — ranging from the user interface you interact with, to internal engines that interpret and display content.</p>
<hr />
<h2 id="heading-main-parts-of-a-browser-high-level">Main Parts of a Browser (High-Level)</h2>
<p>A typical browser consists of the following major parts:</p>
<h3 id="heading-1-user-interface-ui">1. <strong>User Interface (UI)</strong></h3>
<p>This is what you see and interact with:</p>
<ul>
<li><p>Address bar</p>
</li>
<li><p>Tabs</p>
</li>
<li><p>Back/forward buttons</p>
</li>
<li><p>Bookmarks</p>
</li>
<li><p>Window controls</p>
</li>
</ul>
<p>These are all <strong>UI elements</strong> that make the browser usable, but not involved in actual page processing.</p>
<hr />
<h3 id="heading-2-browserrendering-engine">2. <strong>Browser/Rendering Engine</strong></h3>
<p>This is the core that turns downloaded content into what you see:</p>
<ul>
<li><p><strong>Browser engine:</strong> The control center that coordinates between UI and rendering.</p>
</li>
<li><p><strong>Rendering engine:</strong> Parses HTML and CSS; builds internal structures and renders the page visually. Different browsers use different engines (for example, Chrome uses <em>Blink</em>, Firefox uses <em>Gecko</em>).</p>
</li>
</ul>
<hr />
<h3 id="heading-3-networking">3. <strong>Networking</strong></h3>
<p>This component handles communication over the internet. When you hit Enter:</p>
<ol>
<li><p>Browser obtains the URL you typed.</p>
</li>
<li><p>It resolves the host via DNS and establishes a network connection.</p>
</li>
<li><p>It sends an appropriate <strong>HTTP request</strong> to the server.</p>
</li>
<li><p>It receives raw response data — usually HTML, CSS, JavaScript, and assets (images, videos).</p>
</li>
</ol>
<hr />
<h3 id="heading-4-html-parsing-dom">4. <strong>HTML Parsing → DOM</strong></h3>
<p>Once raw bytes of HTML are received, the browser:</p>
<ul>
<li><p>Converts raw bytes into text.</p>
</li>
<li><p><strong>Parses HTML into tokens and builds a tree structure</strong> called the <strong>Document Object Model (DOM)</strong>.</p>
</li>
<li><p>Each HTML element becomes a node in this tree, representing the structure of the page.</p>
</li>
</ul>
<hr />
<h3 id="heading-5-css-parsing-cssom">5. <strong>CSS Parsing → CSSOM</strong></h3>
<p>Separately, CSS files and style blocks are parsed and combined into the <strong>CSS Object Model (CSSOM)</strong> — another tree structure describing how elements should look (styles, selectors, properties).</p>
<hr />
<h2 id="heading-combining-structure-and-style-render-tree">Combining Structure and Style: Render Tree</h2>
<p>After both DOM and CSSOM are ready:</p>
<ul>
<li><p>The browser combines them into a <strong>Render Tree</strong>.</p>
</li>
<li><p>The Render Tree contains only the elements that will actually be <strong>displayed on the page</strong> — invisible elements (like those with <code>display: none</code>) are excluded.</p>
</li>
</ul>
<hr />
<h2 id="heading-layout">Layout</h2>
<p>With the Render Tree constructed:</p>
<ul>
<li><p>The browser computes <strong>exact sizes, positions, and geometry</strong> for every element.</p>
</li>
<li><p>This step determines <em>where</em> everything goes on the screen — it’s called <strong>layout</strong> or <strong>reflow</strong>.</p>
</li>
</ul>
<hr />
<h2 id="heading-painting-and-display">Painting and Display</h2>
<p>Finally:</p>
<ul>
<li><p>The browser <strong>paints</strong> visual elements — filling in pixels, colors, text, images, borders, shadows, etc.</p>
</li>
<li><p>Depending on the browser’s architecture, this might be done in layers and composed into the final screen output.</p>
</li>
</ul>
<p>This entire pipeline — from receiving HTML bytes to displaying pixels — happens <em>very quickly</em>, usually in milliseconds.</p>
<hr />
<h2 id="heading-parsing-explained">Parsing Explained</h2>
<p>Parsing is similar to understanding a sentence:</p>
<ul>
<li><p>Raw text: <code>"&lt;h1&gt;Hello&lt;/h1&gt;"</code></p>
</li>
<li><p>Parser reads characters → recognizes tags → builds a structured representation (DOM tree).</p>
</li>
</ul>
<p>This structured interpretation helps the browser know “what’s where” before it lays things out.</p>
<hr />
<h2 id="heading-summary-browser-journey">Summary: Browser Journey</h2>
<p>Here’s the simplified flow from <strong>URL to screen</strong>:</p>
<ol>
<li><p><strong>User enters URL</strong> and presses Enter.</p>
</li>
<li><p>Browser sends a network request and gets HTML, CSS, JS.</p>
</li>
<li><p><strong>HTML is parsed</strong> → DOM tree created.</p>
</li>
<li><p><strong>CSS is parsed</strong> → CSSOM created.</p>
</li>
<li><p><strong>DOM + CSSOM → Render Tree</strong> (visible structure + style).</p>
</li>
<li><p><strong>Layout (Reflow)</strong> calculates positions &amp; dimensions.</p>
</li>
<li><p><strong>Paint</strong> draws pixels to the screen.</p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Emmet for HTML: A Beginner’s Guide to Writing Faster Markup]]></title><description><![CDATA[What Emmet Is (in Simple Terms)
Emmet is a tool built into many modern code editors that lets you type shortcuts (abbreviations) instead of full HTML code and instantly expand them into full markup. It’s like writing a short shorthand that the editor...]]></description><link>https://birendra.site/emmet-for-html-a-beginners-guide-to-writing-faster-markup</link><guid isPermaLink="true">https://birendra.site/emmet-for-html-a-beginners-guide-to-writing-faster-markup</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sat, 31 Jan 2026 07:59:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769846303812/be9b2ee6-e844-473a-b2c4-f945cf084a7d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-emmet-is-in-simple-terms">What Emmet Is (in Simple Terms)</h2>
<p><strong>Emmet</strong> is a <strong>tool built into many modern code editors</strong> that lets you <strong>type shortcuts (abbreviations) instead of full HTML code</strong> and instantly expand them into full markup. It’s like writing a short shorthand that the editor <em>expands into HTML for you</em>.</p>
<p>It used to be called “Zen Coding” and was designed specifically to speed up coding for <strong>HTML and other structured languages</strong> like XML.</p>
<hr />
<h2 id="heading-why-emmet-is-useful-for-beginners">Why Emmet Is Useful for Beginners</h2>
<p>Writing HTML manually — especially long structures like boilerplates, nested lists, or forms — can feel <strong>slow and repetitive</strong>. Emmet saves time by letting you <strong>write less and generate more</strong> quickly. It’s especially helpful if you’re just <strong>learning HTML</strong> and want to focus on structure instead of typing every tag.</p>
<hr />
<h2 id="heading-how-emmet-works-in-code-editors">How Emmet Works in Code Editors</h2>
<p>Most editors like <strong>Visual Studio Code, Sublime Text, Atom, and WebStorm</strong> come with Emmet included or available as a plugin. You usually:</p>
<ol>
<li><p>Type an <strong>Emmet abbreviation</strong> — a short line that resembles CSS selector syntax.</p>
</li>
<li><p>Press the <strong>Tab</strong> key (or sometimes <strong>Enter</strong>) to expand it into full HTML.</p>
</li>
</ol>
<p>For example, typing <code>div</code> then pressing <strong>Tab</strong> will expand into <code>&lt;div&gt;&lt;/div&gt;</code>.</p>
<hr />
<h2 id="heading-basic-emmet-syntax-and-abbreviations">Basic Emmet Syntax and Abbreviations</h2>
<p>Emmet abbreviations look a lot like <strong>CSS selectors</strong> and include operators that define structure:</p>
<ul>
<li><p><code>&gt;</code> → child element</p>
</li>
<li><p><code>+</code> → sibling elements</p>
</li>
<li><p><code>*n</code> → repeat <em>n</em> times</p>
</li>
<li><p><code>.</code> → class</p>
</li>
<li><p><code>#</code> → ID</p>
</li>
</ul>
<p>Example:</p>
<pre><code class="lang-javascript">div#page&gt;ul&gt;li*<span class="hljs-number">3</span>
</code></pre>
<p>After pressing Tab, this expands to:</p>
<pre><code class="lang-javascript">&lt;div id=<span class="hljs-string">"page"</span>&gt;
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span></span>
&lt;/div&gt;
</code></pre>
<hr />
<h2 id="heading-creating-html-elements-with-emmet">Creating HTML Elements with Emmet</h2>
<p>Here are some common Emmet commands you’ll use:</p>
<ul>
<li><p><strong>Single element:</strong><br />  <code>p</code> → <code>&lt;p&gt;&lt;/p&gt;</code></p>
</li>
<li><p><strong>Element with class:</strong><br />  <code>.container</code> → <code>&lt;div class="container"&gt;&lt;/div&gt;</code></p>
</li>
<li><p><strong>Element with ID:</strong><br />  <code>#header</code> → <code>&lt;div id="header"&gt;&lt;/div&gt;</code></p>
</li>
<li><p><strong>Nested elements:</strong><br />  <code>div&gt;ul&gt;li</code> → creates a <code>&lt;div&gt;</code> with a <code>&lt;ul&gt;</code> and a nested <code>&lt;li&gt;</code>.</p>
</li>
</ul>
<hr />
<h2 id="heading-adding-classes-ids-and-attributes">Adding Classes, IDs, and Attributes</h2>
<p>You can combine symbols to add classes, IDs, and attributes without writing them manually:</p>
<ul>
<li><p><code>.btn.primary</code> → <code>&lt;div class="btn primary"&gt;&lt;/div&gt;</code></p>
</li>
<li><p><code>a[href="</code><a target="_blank" href="https://example.com"><code>https://example.com</code></a><code>"]</code> → <code>&lt;a href="</code><a target="_blank" href="https://example.com&quot;&gt;&lt;/a&gt;"><code>https://example.com"&gt;&lt;/a&gt;</code></a></p>
</li>
</ul>
<p>This removes the need for repetitive typing when adding attributes.</p>
<hr />
<h2 id="heading-creating-nested-structures">Creating Nested Structures</h2>
<p>Using <strong>child (</strong><code>&gt;</code>) and <strong>sibling (</strong><code>+</code>) operators, you can quickly build complex hierarchies:</p>
<ul>
<li><p><strong>Nested:</strong><br />  <code>header&gt;nav&gt;ul&gt;li*4</code> expands into a navigation list with four items.</p>
</li>
<li><p><strong>Siblings:</strong><br />  <code>h1+p+a</code> → creates <code>&lt;h1&gt;</code>, a <code>&lt;p&gt;</code>, and an <code>&lt;a&gt;</code> all at the same level.</p>
</li>
</ul>
<hr />
<h2 id="heading-repeating-elements-using-multiplication">Repeating Elements Using Multiplication</h2>
<p>Want multiple copies of the same element?</p>
<p>Example:</p>
<pre><code class="lang-javascript">li*<span class="hljs-number">5</span>
</code></pre>
<p>→ generates five <code>&lt;li&gt;&lt;/li&gt;</code> elements.<br />You can even use <code>$</code> to insert numbering:</p>
<pre><code class="lang-javascript">li.item$*<span class="hljs-number">3</span>
</code></pre>
<p>→ produces <code>item1</code>, <code>item2</code>, <code>item3</code> respectively inside the repeated elements.</p>
<hr />
<h2 id="heading-generating-full-html-boilerplate">Generating Full HTML Boilerplate</h2>
<p>One of the biggest time savers is generating a complete HTML5 structure instantly:</p>
<ul>
<li><p><code>!</code> or</p>
</li>
<li><p><code>html:5</code></p>
</li>
</ul>
<p>When you type either of these in a blank HTML file and hit <strong>Tab</strong>, Emmet will generate the complete <code>&lt;!DOCTYPE html&gt;</code> and <code>&lt;html&gt;&lt;head&gt;…&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;</code> boilerplate for you.</p>
<hr />
<h2 id="heading-suggestions-for-beginners">Suggestions for Beginners</h2>
<ul>
<li><p>Try Emmet <strong>one concept at a time</strong> — start with single elements, then move to nested structures.</p>
</li>
<li><p>Compare the <strong>Emmet abbreviation</strong> vs. the <strong>expanded HTML</strong> side-by-side.</p>
</li>
<li><p>Practice using it in an editor like <strong>VS Code</strong>, which has Emmet built in by default.</p>
</li>
<li><p>Emmet is <strong>optional</strong> — it’s meant to help you <em>write markup faster</em>, but you can still create HTML without it.</p>
</li>
</ul>
<hr />
<h2 id="heading-summary">Summary</h2>
<p>Emmet is a <strong>powerful shorthand toolkit</strong> that lets you expand <strong>simple abbreviations into full HTML structures quickly</strong>, making HTML coding faster and less repetitive. It’s widely supported across editors, requires minimal setup, and uses a CSS-like syntax that feels intuitive if you’re already familiar with HTML or CSS.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding HTML Tags and Elements]]></title><description><![CDATA[What Is HTML and Why Do We Use It
HTML (HyperText Markup Language) is the standard language used to create and structure content on the web — it tells browsers what content is and how it should be organized.
Think of HTML as the skeleton of a webpage...]]></description><link>https://birendra.site/understanding-html-tags-and-elements</link><guid isPermaLink="true">https://birendra.site/understanding-html-tags-and-elements</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sat, 31 Jan 2026 06:49:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769842140182/137f304a-f16a-4ad5-ae72-a416595866b3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-html-and-why-do-we-use-it">What Is HTML and Why Do We Use It</h2>
<p><strong>HTML (HyperText Markup Language)</strong> is the standard language used to create and structure content on the web — it tells browsers <em>what</em> content is and <em>how</em> it should be organized.</p>
<p>Think of HTML as the <strong>skeleton of a webpage</strong>: without it you’d just have plain text with no structure or meaning. HTML lets you define headings, paragraphs, links, images, lists, and more.</p>
<hr />
<h2 id="heading-what-is-an-html-tag">What Is an HTML Tag?</h2>
<p>An <strong>HTML tag</strong> is a keyword wrapped in angle brackets (<code>&lt;</code> and <code>&gt;</code>). Tags act like labels that tell the browser about the content inside them.</p>
<p>Example tags:</p>
<pre><code class="lang-javascript">&lt;h1&gt;
&lt;p&gt;
&lt;a&gt;
</code></pre>
<p>Tags usually come in pairs — an <strong>opening tag</strong> (e.g., <code>&lt;p&gt;</code>) and a <strong>closing tag</strong> (e.g., <code>&lt;/p&gt;</code>). The closing tag has a slash to show where the element ends.</p>
<hr />
<h2 id="heading-what-is-an-html-element">What Is an HTML Element?</h2>
<p>An <strong>HTML element</strong> is everything from the <strong>start tag</strong> to the <strong>end tag</strong> <em>including</em> the content between them.</p>
<p><strong>Element = opening tag + content + closing tag</strong><br />Example:</p>
<pre><code class="lang-javascript">&lt;p&gt;Hello, world!&lt;/p&gt;
</code></pre>
<p>Together, this tells the browser: <em>display “Hello, world!” as a paragraph.</em></p>
<h3 id="heading-self-closing-void-elements">Self-Closing (Void) Elements</h3>
<p>Some elements don’t wrap around content; they exist on their own. For example:</p>
<pre><code class="lang-javascript">&lt;br&gt;
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"image.jpg"</span>&gt;</span></span>
</code></pre>
<p>These are called <strong>self-closing</strong> or <strong>void elements</strong> — they don’t have closing tags.</p>
<hr />
<h2 id="heading-block-level-vs-inline-elements">Block-Level vs Inline Elements</h2>
<p>HTML elements behave differently on the page depending on how they are displayed:</p>
<h3 id="heading-block-level-elements">Block-Level Elements</h3>
<ul>
<li><p>Start on a <strong>new line</strong></p>
</li>
<li><p>Take up the <strong>full width</strong> available</p>
</li>
<li><p>Often used for main structure sections</p>
</li>
<li><p>Examples: <code>&lt;div&gt;</code>, <code>&lt;p&gt;</code>, <code>&lt;h1&gt;</code></p>
</li>
</ul>
<pre><code class="lang-javascript">&lt;div&gt;This is a block.&lt;/div&gt;
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This starts on its own line.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>
</code></pre>
<h3 id="heading-inline-elements">➿ Inline Elements</h3>
<ul>
<li><p>Stay <strong>inside text flow</strong></p>
</li>
<li><p>Only take up as much width as needed</p>
</li>
<li><p>Often used within other elements</p>
</li>
<li><p>Examples: <code>&lt;span&gt;</code>, <code>&lt;a&gt;</code>, <code>&lt;strong&gt;</code></p>
</li>
</ul>
<pre><code class="lang-javascript">&lt;p&gt;This is &lt;span&gt;inline&lt;<span class="hljs-regexp">/span&gt; in a paragraph.&lt;/</span>p&gt;
</code></pre>
<p><strong>Tip:</strong> Block elements build structure; inline elements refine content inside that structure.</p>
<hr />
<h2 id="heading-common-html-tags-youll-see-first">Common HTML Tags You’ll See First</h2>
<p>Here are some fundamental tags used in most HTML pages:</p>
<ul>
<li><p><code>&lt;html&gt;</code> – The root element of an HTML document</p>
</li>
<li><p><code>&lt;head&gt;</code> – Metadata container (title, scripts, styles)</p>
</li>
<li><p><code>&lt;body&gt;</code> – Main visible page content</p>
</li>
<li><p><code>&lt;h1&gt;</code> to <code>&lt;h6&gt;</code> – Headings, with <code>&lt;h1&gt;</code> largest</p>
</li>
<li><p><code>&lt;p&gt;</code> – Paragraph text</p>
</li>
<li><p><code>&lt;a&gt;</code> – Hyperlink</p>
</li>
<li><p><code>&lt;img&gt;</code> – Image (self-closing)</p>
</li>
<li><p><code>&lt;div&gt;</code> – Generic block container</p>
</li>
<li><p><code>&lt;span&gt;</code> – Generic inline container</p>
</li>
</ul>
<p>These tags help you define structure and content quickly.</p>
<hr />
<h2 id="heading-tag-vs-element-whats-the-difference">Tag vs Element: What’s the Difference?</h2>
<ul>
<li><p><strong>Tag:</strong> A part of markup (<code>&lt;p&gt;</code>, <code>&lt;/p&gt;</code>).</p>
</li>
<li><p><strong>Element:</strong> A complete unit of content including tags and what’s inside them.</p>
</li>
</ul>
<p>In casual discussion, people often use “tag” and “element” interchangeably, but <em>technically</em>, the tag is just the markup while the element is the whole construct.</p>
<hr />
<h2 id="heading-try-it-yourself">Try It Yourself</h2>
<p>Open any webpage in your browser, right-click, and choose <strong>Inspect</strong> or <strong>View Page Source</strong>. You’ll see HTML in action — that’s your chance to practice recognizing tags and elements!</p>
<hr />
<h2 id="heading-summary">Summary</h2>
<ul>
<li><p><strong>HTML</strong> is the skeleton language of the web.</p>
</li>
<li><p><strong>Tags</strong> are markers used to describe content.</p>
</li>
<li><p><strong>Elements</strong> include tags and the content they wrap.</p>
</li>
<li><p>Some elements are <strong>self-closing/void</strong> (e.g., <code>&lt;br&gt;</code>, <code>&lt;img&gt;</code>).</p>
</li>
<li><p>Elements can be <strong>block-level</strong> or <strong>inline</strong> depending on how they layout on the page.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[TCP Working: 3-Way Handshake & Reliable Communication]]></title><description><![CDATA[What Is TCP and Why It Needed
TCP (Transmission Control Protocol) is a connection-oriented transport protocol used on the Internet to send data reliably between two applications. It sits at the transport layer above the IP layer. Because IP can lose,...]]></description><link>https://birendra.site/tcp-working-3-way-handshake-and-reliable-communication</link><guid isPermaLink="true">https://birendra.site/tcp-working-3-way-handshake-and-reliable-communication</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sat, 31 Jan 2026 06:10:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769839810132/41880661-0356-4806-8a63-bec8620867fa.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-tcp-and-why-it-needed">What Is TCP and Why It Needed</h2>
<p><strong>TCP (Transmission Control Protocol)</strong> is a <strong>connection-oriented transport protocol</strong> used on the Internet to send data reliably between two applications. It sits at the transport layer above the IP layer. Because IP can lose, reorder, or duplicate packets, TCP adds rules so that both sides can <strong>detect errors</strong>, <strong>recover lost packets</strong>, and <strong>reassemble</strong> data correctly at the receiver.</p>
<p>Without TCP or a similar protocol, even simple message delivery over an unreliable network could result in missing or corrupted files, confusing errors, or out-of-order information arriving at the destination.</p>
<hr />
<h2 id="heading-what-problems-tcp-solves">What Problems TCP Solves</h2>
<p>TCP is designed to handle common network issues:</p>
<ul>
<li><p><strong>Lost packets</strong> — if a packet doesn’t arrive, TCP requests it again.</p>
</li>
<li><p><strong>Out-of-order packets</strong> — packets may arrive in a different sequence than sent; TCP reorders them correctly.</p>
</li>
<li><p><strong>Duplicate packets</strong> — TCP detects and removes duplicates.</p>
</li>
<li><p><strong>Flow and congestion control</strong> — TCP adjusts data flow based on network and receiver capacity.</p>
</li>
</ul>
<hr />
<h2 id="heading-what-is-the-3-way-handshake">What Is the 3-Way Handshake?</h2>
<p>Before any application data is sent, TCP sets up a reliable connection using a <strong>3-way handshake</strong>: a conversation between the client and server to agree that both are ready and synchronized.</p>
<h3 id="heading-a-simple-analogy">A Simple Analogy</h3>
<p>Imagine two people meeting by phone:</p>
<ol>
<li><p><strong>Caller:</strong> “Are you there?”</p>
</li>
<li><p><strong>Receiver:</strong> “Yes — and <em>I’m ready. Are you there?</em>”</p>
</li>
<li><p><strong>Caller:</strong> “Yes, I’m ready — let’s talk!”</p>
</li>
</ol>
<p>Only after this mutual confirmation does the real conversation start. TCP’s handshake works the same way.</p>
<hr />
<h2 id="heading-step-by-step-syn-syn-ack-ack">Step-by-Step: SYN, SYN-ACK, ACK</h2>
<p>Each step uses TCP flags to communicate intentions:</p>
<ol>
<li><p><strong>SYN (Synchronize):</strong><br /> The client sends a packet with the <strong>SYN</strong> flag to the server — this means <em>“I want to open a connection.”</em></p>
</li>
<li><p><strong>SYN-ACK (Synchronize &amp; Acknowledge):</strong><br /> The server responds with a packet that has <strong>both SYN and ACK flags</strong> set:</p>
<ul>
<li><p>ACK confirms it received the client’s SYN.</p>
</li>
<li><p>SYN tells the client <em>“I agree, and I also want to open a connection to you.”</em></p>
</li>
</ul>
</li>
<li><p><strong>ACK (Acknowledge):</strong><br /> The client replies with an <strong>ACK</strong> packet back to the server — now both sides know the other is ready and synchronized.</p>
</li>
</ol>
<p>Once this exchange completes, the TCP connection is established and ready for real data transfer.</p>
<hr />
<h2 id="heading-how-tcp-ensures-reliable-ordered-communication">How TCP Ensures Reliable, Ordered Communication</h2>
<p>After the handshake:</p>
<ul>
<li><p>TCP uses <strong>sequence numbers</strong> to track each byte of data, so the receiver can <strong>reassemble</strong> data in order.</p>
</li>
<li><p>The receiver sends <strong>ACKs</strong> for received data; if a packet is lost, the sender <strong>retransmits</strong> it.</p>
</li>
<li><p>If network conditions change, TCP adjusts how fast packets are sent to avoid congestion.</p>
</li>
</ul>
<p>This combination of synchronized sequence numbers and acknowledgments is what makes TCP <strong>reliable</strong>, even over unpredictable networks.</p>
<hr />
<h2 id="heading-closing-a-tcp-connection">Closing a TCP Connection</h2>
<p>When communication is done, TCP doesn’t just stop — it <strong>closes the connection gracefully</strong> using a similar handshake process:</p>
<ul>
<li><p>One endpoint sends <strong>FIN</strong> (finish) to indicate it has no more to send.</p>
</li>
<li><p>The other acknowledges with <strong>ACK</strong>.</p>
</li>
<li><p>Often each side goes through this <em>four-step</em> procedure (FIN → ACK → FIN → ACK) to allow both directions to finish independently.</p>
</li>
</ul>
<p>This ensures that all data has been fully transmitted and acknowledged before the connection truly ends.</p>
<hr />
<h2 id="heading-summary">Summary</h2>
<ul>
<li><p><strong>TCP</strong> provides <strong>reliability and correctness</strong> on top of the basic, unreliable IP network by detecting errors and retransmitting missing data.</p>
</li>
<li><p>The <strong>3-way handshake</strong> is the foundation of TCP’s connection-oriented behavior — it makes sure both ends are ready and synchronized before sending real data.</p>
</li>
<li><p><strong>Sequence numbers and ACKs</strong> allow TCP to maintain order, detect loss, and manage flow.</p>
</li>
<li><p>Connection close uses a similar handshake mechanism to ensure a clean end.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[TCP vs UDP: When to Use What, and How TCP Relates to HTTP]]></title><description><![CDATA[Why We Need Protocols
When data travels over the internet, it needs rules so that both sides — sender and receiver — understand how to communicate. These rules are called protocols. Think of them as agreed standards for sending and receiving messages...]]></description><link>https://birendra.site/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http</link><guid isPermaLink="true">https://birendra.site/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sat, 31 Jan 2026 05:58:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769839052121/6aee999b-6188-4035-b24d-73f005a5df78.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-why-we-need-protocols">Why We Need Protocols</h2>
<p>When data travels over the internet, it needs <em>rules</em> so that both sides — sender and receiver — understand <em>how</em> to communicate. These rules are called <strong>protocols</strong>. Think of them as agreed standards for sending and receiving messages across a network.</p>
<p>At the broadest level:</p>
<ul>
<li><p><strong>IP</strong> (Internet Protocol) routes packets between computers.</p>
</li>
<li><p><strong>TCP</strong> and <strong>UDP</strong> sit on top of IP and help deliver that data between applications.</p>
</li>
<li><p><strong>HTTP</strong> sits even higher — it defines <em>what</em> data means, not how it gets delivered.</p>
</li>
</ul>
<hr />
<h2 id="heading-what-are-tcp-and-udp">What Are TCP and UDP?</h2>
<h3 id="heading-tcp-transmission-control-protocol"><strong>TCP – Transmission Control Protocol</strong></h3>
<ul>
<li><p>A <strong>reliable, connection-oriented</strong> transport protocol at the Transport Layer (Layer 4).</p>
</li>
<li><p>Before data flows, it establishes a “connection” between sender and receiver.</p>
</li>
<li><p>Every piece of data sent is acknowledged — if packets are lost, TCP <em>retransmits</em> them.</p>
</li>
<li><p>It ensures <strong>ordered delivery</strong> and <strong>complete data</strong> at the destination.</p>
</li>
</ul>
<p><strong>Analogy:</strong> Like a <strong>tracked courier service</strong> — you send items and receive confirmations that each one arrived safely.</p>
<hr />
<h3 id="heading-udp-user-datagram-protocol"><strong>UDP – User Datagram Protocol</strong></h3>
<ul>
<li><p>A <strong>connectionless</strong> transport protocol at the same layer.</p>
</li>
<li><p>UDP sends packets (“datagrams”) without setting up a connection or tracking delivery.</p>
</li>
<li><p>There are <strong>no guarantees</strong>: packets may arrive out of order, be delayed, or be lost.</p>
</li>
</ul>
<p><strong>Analogy:</strong> Like a <strong>public announcement broadcast</strong> — you send the message, but you don’t know who hears it or if they catch every word.</p>
<hr />
<h2 id="heading-key-differences">🔑 Key Differences</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>TCP</td><td>UDP</td></tr>
</thead>
<tbody>
<tr>
<td>Connection</td><td>Yes — establishes a reliable link</td><td>No — just fires off packets</td></tr>
<tr>
<td>Reliability</td><td>✔ Guaranteed delivery</td><td>✘ Not guaranteed</td></tr>
<tr>
<td>Ordering</td><td>✔ Ensures in-order delivery</td><td>✘ No order guarantees</td></tr>
<tr>
<td>Speed</td><td>Slower (overhead for reliability)</td><td>Faster (minimal overhead)</td></tr>
<tr>
<td>Use Case</td><td>Data integrity matters</td><td>Speed &amp; low latency matter</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-when-to-use-tcp">🧠 When to Use TCP</h2>
<p>Choose TCP when <strong>reliability and correctness matter</strong> — when missing data would break the application.</p>
<p><strong>Typical uses:</strong></p>
<ul>
<li><p><strong>Web browsing:</strong> loading web pages (HTML, CSS, JS) accurately.</p>
</li>
<li><p><strong>File transfers</strong> (FTP, SFTP).</p>
</li>
<li><p><strong>Email</strong> (SMTP, IMAP, POP3).</p>
</li>
<li><p><strong>Remote access</strong> (SSH, Telnet).</p>
</li>
<li><p><strong>Online banking/financial transactions.</strong></p>
</li>
</ul>
<p><strong>Why?</strong> Because if even a small piece is missing or out of order, you get corrupted content or errors.</p>
<p><strong>Analogy:</strong> Ensuring every paragraph arrives in a book exactly as written.</p>
<hr />
<h2 id="heading-when-to-use-udp">When to Use UDP</h2>
<p>Choose UDP when <strong>speed is more important than perfect delivery</strong> — especially for real-time or high-throughput apps.</p>
<p><strong>Typical uses:</strong></p>
<ul>
<li><p><strong>Live video &amp; audio streaming</strong> (some loss is acceptable).</p>
</li>
<li><p><strong>VoIP and video calls.</strong></p>
</li>
<li><p><strong>Online multiplayer games.</strong></p>
</li>
<li><p><strong>DNS lookups</strong> (small, simple requests).</p>
</li>
</ul>
<p><strong>Why?</strong> You’d rather have continuous flow than stall due to retries.</p>
<p><strong>Analogy:</strong> Streaming music where a skipped note is better than a long silence.</p>
<hr />
<h2 id="heading-real-world-examples-tcp-vs-udp">Real-World Examples: TCP vs UDP</h2>
<p><strong>TCP Examples</strong></p>
<ul>
<li><p>Visiting a news website</p>
</li>
<li><p>Sending an email</p>
</li>
<li><p>Downloading an app update</p>
</li>
</ul>
<p><strong>UDP Examples</strong></p>
<ul>
<li><p>Zoom/Teams video calls</p>
</li>
<li><p>Multiplayer gaming</p>
</li>
<li><p>Real-time telemetry/sensors</p>
</li>
</ul>
<p>These reflect the fundamental trade-off: <strong>integrity vs speed</strong>.</p>
<hr />
<h2 id="heading-what-is-http">What Is HTTP?</h2>
<p><strong>HTTP</strong> stands for <strong>Hypertext Transfer Protocol</strong>. It’s an <strong>application-level protocol</strong> used by web browsers and servers to request and send web content like HTML, images, and APIs.</p>
<ul>
<li><p>HTTP defines <em>what the messages mean</em> — e.g., GET this page, POST this form.</p>
</li>
<li><p>HTTP does <strong>not define how bits travel between computers</strong>.</p>
</li>
</ul>
<p><strong>Key point:</strong> HTTP runs <strong>on top of TCP</strong>, not instead of it. Even though HTTP is universally used for the web, it depends on a transport protocol under the hood.</p>
<hr />
<h2 id="heading-how-tcp-and-http-relate">How TCP and HTTP Relate</h2>
<ul>
<li><p><strong>HTTP is an application-level protocol</strong> — it’s what web clients/servers speak to understand content.</p>
</li>
<li><p><strong>TCP is a transport-level protocol</strong> — it reliably moves HTTP messages between machines over the network.</p>
</li>
</ul>
<p><strong>Common confusion:</strong></p>
<ul>
<li><em>“Is HTTP the same as TCP?”</em> — No. HTTP uses TCP but isn’t a replacement. TCP is the <em>delivery mechanism</em>, HTTP is the <em>content semantics</em>.</li>
</ul>
<hr />
<h2 id="heading-short-analogies-to-remember">Short Analogies to Remember</h2>
<ul>
<li><p><strong>TCP:</strong> Reliable phone call — you hear everything, and missing info gets repeated.</p>
</li>
<li><p><strong>UDP:</strong> Loudspeaker announcement — quick and wide, but some people might miss bits.</p>
</li>
<li><p><strong>HTTP:</strong> The language you use during the call — what the message <em>means</em>.</p>
</li>
</ul>
<hr />
<h2 id="heading-summary">🧩 Summary</h2>
<ol>
<li><p><strong>TCP and UDP</strong> are transport protocols — TCP is safe and reliable, UDP is fast and simple.</p>
</li>
<li><p><strong>Use TCP</strong> when you need data correctness (web pages, files).</p>
</li>
<li><p><strong>Use UDP</strong> when speed matters more than every byte arriving (live media, games).</p>
</li>
<li><p><strong>HTTP is an application protocol</strong> that runs on top of TCP to exchange web content.</p>
</li>
<li><p><strong>HTTP does not replace TCP</strong> — it relies on TCP for delivery</p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Understanding Network Devices]]></title><description><![CDATA[In modern computer networks, a variety of specialized devices work together to connect users to the internet, manage internal traffic, and keep data flowing efficiently and securely. From the modem that links your home to your Internet Service Provid...]]></description><link>https://birendra.site/understanding-network-devices</link><guid isPermaLink="true">https://birendra.site/understanding-network-devices</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Tue, 27 Jan 2026 08:34:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769502865263/57d14a32-8b03-49c7-b6b1-a309ac298f7e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In modern computer networks, a variety of specialized devices work together to connect users to the internet, manage internal traffic, and keep data flowing efficiently and securely. From the modem that links your home to your Internet Service Provider, to routers that direct traffic between networks, and advanced systems like firewalls and load balancers that protect and scale services — each component plays a distinct role. Understanding these devices, how they differ, and how they interplay lays the foundation for grasping how data travels from your screen to servers around the world and back again.</p>
<h2 id="heading-1-what-is-a-modem-your-link-to-the-internet">📡 1. <strong>What Is a Modem? — Your Link to the Internet</strong></h2>
<p>A <strong>modem</strong> (<em>modulator–demodulator</em>) is the device that <strong>connects your home/office network to the wider Internet</strong>. It sits at the boundary between your household network and your ISP (Internet Service Provider).</p>
<h3 id="heading-what-it-does">What it does</h3>
<ul>
<li><p>Converts the <strong>digital signals</strong> used inside your network into a <strong>format the ISP’s infrastructure understands</strong> (and vice-versa).</p>
</li>
<li><p>Handles the physical signalling over cable, DSL, fiber, or cellular links — essentially translating electrical/light/radio signals.</p>
</li>
</ul>
<h3 id="heading-how-it-connects-to-the-internet">How it connects to the internet</h3>
<ol>
<li><p>The modem connects to your ISP via a physical line (cable/DSL/fiber).</p>
</li>
<li><p>It negotiates a connection and establishes a <strong>link</strong>.</p>
</li>
<li><p>It delivers <strong>IP-formatted traffic</strong> into your local network.</p>
</li>
</ol>
<p>👉 In many setups, the modem only <em>provides connection</em>, not routing or traffic management.</p>
<hr />
<h2 id="heading-2-what-is-a-router-traffic-director-for-networks">🛣 2. <strong>What Is a Router? — Traffic Director for Networks</strong></h2>
<p>A <strong>router</strong> is the device that <strong>directs traffic between networks</strong> — most commonly between <strong>your LAN (local network)</strong> and the <strong>Internet (WAN)</strong>.</p>
<h3 id="heading-how-it-directs-traffic">How it directs traffic</h3>
<ul>
<li><p>Uses <strong>IP addresses</strong> to decide where packets should go (which network and which path).</p>
</li>
<li><p>Maintains a <strong>routing table</strong> with paths to different destinations.</p>
</li>
<li><p>Often performs <strong>NAT (Network Address Translation)</strong> so multiple local devices share one public IP.</p>
</li>
</ul>
<p>In typical home environments:</p>
<ul>
<li><p>The router connects to the modem via its WAN port.</p>
</li>
<li><p>All LAN devices (wired or Wi-Fi) get their IP configuration from the router.</p>
</li>
</ul>
<hr />
<h2 id="heading-3-switch-vs-hub-local-network-traffic-inside-a-lan">🔁 3. <strong>Switch vs Hub — Local Network Traffic Inside a LAN</strong></h2>
<h3 id="heading-hub-broadcast-everywhere">🟡 Hub — “Broadcast Everywhere”</h3>
<ul>
<li><p>A legacy, <strong>Layer 1</strong> physical device that repeats incoming signals to <em>all</em> ports.</p>
</li>
<li><p>No intelligence — every connected device sees all traffic.</p>
</li>
<li><p>Causes collisions and wastes bandwidth.</p>
</li>
<li><p>Rarely used today.</p>
</li>
</ul>
<h3 id="heading-switch-smart-local-connector">🟢 Switch — “Smart Local Connector”</h3>
<ul>
<li><p>A <strong>Layer 2</strong> device that learns and uses <strong>MAC addresses</strong> to forward frames <em>only</em> to the correct port.</p>
</li>
<li><p>Creates separate collision domains per port, dramatically improving efficiency compared to hubs.</p>
</li>
<li><p>Handles internal LAN traffic between computers, printers, servers, etc.</p>
</li>
</ul>
<p><strong>Key difference:</strong></p>
<ul>
<li><p><strong>Hub</strong> broadcasts to everyone.</p>
</li>
<li><p><strong>Switch</strong> forwards only to the intended recipient.</p>
</li>
</ul>
<hr />
<h2 id="heading-4-what-is-a-firewall-where-security-lives">🔥 4. <strong>What Is a Firewall? — Where Security Lives</strong></h2>
<p>A <strong>firewall</strong> is a traffic-filtering device (hardware or software) that <strong>controls what data can enter or leave a network</strong>.</p>
<h3 id="heading-why-it-matters">Why it matters</h3>
<ul>
<li><p>Monitors packets based on rules: IP, port, protocol, and sometimes application behavior.</p>
</li>
<li><p>Blocks unauthorized access and threats.</p>
</li>
<li><p>Can be placed at network edges (between local network and Internet) or internally between segments.</p>
</li>
</ul>
<p>In many modern routers, a <strong>firewall function is integrated</strong> — inspecting traffic to prevent attacks as traffic moves in/out of your network.</p>
<hr />
<h2 id="heading-5-what-is-a-load-balancer-scaling-for-high-traffic">⚖️ 5. <strong>What Is a Load Balancer? — Scaling for High Traffic</strong></h2>
<p>A <strong>load balancer</strong> distributes incoming network requests <strong>across multiple backend servers</strong> to improve performance, reliability, and uptime.</p>
<h3 id="heading-why-scalable-systems-need-it">Why scalable systems need it</h3>
<ul>
<li><p>Prevents any one server from being overwhelmed during high traffic.</p>
</li>
<li><p>Can check health of servers and only send traffic to healthy ones.</p>
</li>
<li><p>Often operates at <strong>Layer 4 (TCP/UDP)</strong> or <strong>Layer 7 (HTTP/DNS)</strong> of the networking stack.</p>
</li>
</ul>
<p>Load balancers are especially crucial in data centers and cloud applications where thousands or millions of users may connect concurrently.</p>
<hr />
<h2 id="heading-6-how-these-devices-work-together-real-world-setup">🧩 6. <strong>How These Devices Work Together — Real-World Setup</strong></h2>
<p>Here’s a simplified flow for a typical <strong>home/small network</strong>:</p>
<ol>
<li><p><strong>ISP connection → Modem</strong><br /> Modem brings Internet into your building.</p>
</li>
<li><p><strong>Modem → Router</strong><br /> Router directs traffic between the Internet and your internal network.</p>
</li>
<li><p><strong>Router → Switch</strong> <em>(optional extra)</em><br /> Switch expands your wired network capacity.</p>
</li>
<li><p><strong>Firewall</strong> <em>(integrated or separate)</em><br /> Protects your network from threats.</p>
</li>
<li><p><strong>Servers + Load Balancer</strong> <em>(in business or cloud)</em><br /> Requests are distributed across servers for high availability.</p>
</li>
</ol>
<pre><code class="lang-javascript"> ISP internet
     ↓
   Modem
     ↓
   Router (<span class="hljs-keyword">with</span> Firewall)
     ↓
 Switch — connects PCs, printers, cameras
     ↓
 Load Balancer → Pools <span class="hljs-keyword">of</span> servers
</code></pre>
<p><strong>In corporate deployments</strong>, firewalls and load balancers are placed near critical infrastructure to enforce security and distribute traffic efficiently.</p>
<hr />
<h2 id="heading-summary-of-core-roles">🧠 Summary of Core Roles</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Device</td><td>Main Role</td><td>Operates At</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Modem</strong></td><td>Connects network to Internet</td><td>Physical/Layer 1–2</td></tr>
<tr>
<td><strong>Router</strong></td><td>Routes packets between networks</td><td>Network Layer</td></tr>
<tr>
<td><strong>Switch</strong></td><td>Forwards frames inside LAN</td><td>Data Link Layer</td></tr>
<tr>
<td><strong>Hub</strong></td><td>Simple broadcast device</td><td>Physical Layer</td></tr>
<tr>
<td><strong>Firewall</strong></td><td>Filters/controls network traffic</td><td>Layer 3–7</td></tr>
<tr>
<td><strong>Load Balancer</strong></td><td>Distributes high traffic</td><td>Layer 4/7</td></tr>
</tbody>
</table>
</div>]]></content:encoded></item><item><title><![CDATA[How DNS Resolution Works]]></title><description><![CDATA[The DNS resolver is the first stop in the DNS lookup, and it is responsible for dealing with the client that made the initial request. The resolver starts the sequence of queries that ultimately leads to a URL being translated into the necessary IP a...]]></description><link>https://birendra.site/how-dns-resolution-works</link><guid isPermaLink="true">https://birendra.site/how-dns-resolution-works</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Tue, 27 Jan 2026 08:26:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769502376435/6aca19f2-5784-4cdc-952b-6f77cd76dd26.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The DNS resolver is the first stop in the DNS lookup, and it is responsible for dealing with the client that made the initial request. The resolver starts the sequence of queries that ultimately leads to a URL being translated into the necessary IP address.</p>
<p>Note: A typical uncached DNS lookup will involve both recursive and iterative queries.</p>
<p>It's important to differentiate between a recursive DNS query and a recursive DNS resolver. The query refers to the request made to a DNS resolver requiring the resolution of the query. A DNS recursive resolver is the computer that accepts a recursive query and processes the response by making the necessary requests.</p>
<h2 id="heading-what-are-the-types-of-dns-queries"><strong>What are the types of DNS queries?</strong></h2>
<p>In a typical DNS lookup three types of queries occur. By using a combination of these queries, an optimized process for DNS resolution can result in a reduction of distance traveled. In an ideal situation cached record data will be available, allowing a DNS name server to return a non-recursive query.</p>
<h4 id="heading-3-types-of-dns-queries"><strong>3 types of DNS queries:</strong></h4>
<ol>
<li><p><strong>Recursive query</strong> - In a recursive query, a DNS client requires that a DNS server (typically a DNS recursive resolver) will respond to the client with either the requested resource record or an error message if the resolver can't find the record.</p>
</li>
<li><p><strong>Iterative query</strong> - in this situation the DNS client will allow a DNS server to return the best answer it can. If the queried DNS server does not have a match for the query name, it will return a referral to a DNS server authoritative for a lower level of the domain namespace. The DNS client will then make a query to the referral address. This process continues with additional DNS servers down the query chain until either an error or timeout occurs.</p>
</li>
<li><p><strong>Non-recursive query</strong> - typically this will occur when a DNS resolver client queries a DNS server for a record that it has access to either because it's authoritative for the record or the record exists inside of its cache. Typically, a DNS server will cache DNS records to prevent additional bandwidth consumption and load on upstream servers.</p>
</li>
</ol>
<h2 id="heading-1-what-is-dns-the-internets-phonebook">🌐 1. What is DNS? — <em>The Internet’s Phonebook</em></h2>
<p>The <strong>Domain Name System (DNS)</strong> translates human-friendly names like:</p>
<pre><code class="lang-javascript">google.com
</code></pre>
<p>into machine-usable IP addresses like:</p>
<pre><code class="lang-javascript"><span class="hljs-number">142.250</span><span class="hljs-number">.190</span><span class="hljs-number">.78</span>
</code></pre>
<p>Without DNS, we’d have to memorize numerical IPs for every website — like remembering someone’s phone number instead of their name.</p>
<p>Think of DNS as <strong>the internet’s phonebook</strong>:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Domain Name</td><td>IP Address</td></tr>
</thead>
<tbody>
<tr>
<td><a target="_blank" href="http://google.com"><code>google.com</code></a></td><td><code>142.250.190.78</code></td></tr>
<tr>
<td><a target="_blank" href="http://openai.com"><code>openai.com</code></a></td><td><code>34.201.222.82</code></td></tr>
</tbody>
</table>
</div><p>Your computer asks DNS “What’s the number for this name?” — and DNS gives back the IP.</p>
<hr />
<h2 id="heading-2-introducing-dig-the-dns-diagnostic-tool">🛠 2. Introducing <code>dig</code> — the DNS Diagnostic Tool</h2>
<p><code>dig</code> is a command-line utility used to <strong>query and troubleshoot DNS resolution</strong>.</p>
<p>It lets you see:</p>
<p>✔ What DNS records exist<br />✔ Which DNS server answered your query<br />✔ How long the answer is valid<br />✔ The path your query took through DNS infrastructure</p>
<p>By inspecting the output manually, you build a <em>mental model</em> of how DNS works under the hood.</p>
<hr />
<h2 id="heading-3-how-dns-resolution-works-layer-by-layer">🧱 3. How DNS Resolution Works — <strong>Layer by Layer</strong></h2>
<p>DNS resolution is hierarchical. A recursive resolver does the heavy lifting by navigating this stack:</p>
<pre><code class="lang-javascript">Your Client
    ↓
Recursive Resolver
    ↓
Root Nameservers
    ↓
TLD Nameservers (e.g., .COM)
    ↓
Authoritative Nameservers
    ↑
Answer returned all the way back
</code></pre>
<p>Let’s break that down.</p>
<h3 id="heading-root-nameservers">🌀 <strong>Root Nameservers</strong></h3>
<p>These are the top of the DNS hierarchy. They don’t know your final domain’s IP, but they know where to find the TLD servers.</p>
<h3 id="heading-tld-nameservers">🔤 <strong>TLD Nameservers</strong></h3>
<p>For <code>.com</code>, <code>.org</code>, <code>.net</code>, etc., these hold pointers to authoritative servers for your specific domain.</p>
<h3 id="heading-authoritative-dns">📁 <strong>Authoritative DNS</strong></h3>
<p>This is the final stop — the source of truth for a domain’s DNS records (A, NS, MX, TXT, etc.)</p>
<hr />
<h2 id="heading-4-walkthrough-understanding-dig-outputs">👣 4. Walkthrough: Understanding <code>dig</code> Outputs</h2>
<p>Here’s what running certain <code>dig</code> commands tells you.</p>
<h3 id="heading-1-basic-lookup">1. Basic lookup</h3>
<pre><code class="lang-javascript">dig google.com
</code></pre>
<p>This does:</p>
<ul>
<li><p>Sends query to your default recursive resolver</p>
</li>
<li><p>Asks for the <strong>A record</strong> (IPv4) of <a target="_blank" href="http://google.com">google.com</a></p>
</li>
<li><p>Shows you the answer and details about the query</p>
</li>
</ul>
<p>You’ll see sections like:</p>
<ul>
<li><p><strong>QUESTION SECTION</strong> — what was asked</p>
</li>
<li><p><strong>ANSWER SECTION</strong> — what was returned</p>
</li>
<li><p><strong>AUTHORITY SECTION</strong> — DNS servers that are authoritative</p>
</li>
<li><p><strong>ADDITIONAL SECTION</strong> — extra info like IPs for nameservers</p>
</li>
</ul>
<hr />
<h3 id="heading-2-query-only-ns-records">2. Query only NS records</h3>
<pre><code class="lang-javascript">dig google.com NS
</code></pre>
<p>This asks for <strong>NS (name server) records</strong> — essentially:</p>
<blockquote>
<p>“Which servers are authoritative for this domain?”</p>
</blockquote>
<p>Why NS records matter:</p>
<ul>
<li><p>They tell resolvers <em>who is responsible</em> for answering about that domain</p>
</li>
<li><p>They guide the recursive resolver where to ask next</p>
</li>
</ul>
<p>Example output snippet:</p>
<pre><code class="lang-javascript">google.com.      <span class="hljs-number">86400</span>  IN  NS  ns1.google.com.
google.com.      <span class="hljs-number">86400</span>  IN  NS  ns2.google.com.
</code></pre>
<hr />
<h3 id="heading-3-asking-a-specific-dns-server">3. Asking a specific DNS server</h3>
<pre><code class="lang-javascript">dig @<span class="hljs-number">8.8</span><span class="hljs-number">.8</span><span class="hljs-number">.8</span> google.com
</code></pre>
<p>This:</p>
<ul>
<li><p>Tells <code>dig</code> to query <strong>Google’s public DNS</strong> (8.8.8.8) instead of your default resolver</p>
</li>
<li><p>Helpful to compare resolver behavior</p>
</li>
</ul>
<hr />
<h2 id="heading-5-what-are-ns-records-and-why-they-matter">🧠 5. What Are NS Records and Why They Matter</h2>
<p><strong>NS (Name Server) records</strong> list DNS servers authoritative for a domain.</p>
<p>They matter because:</p>
<p>✔ They tell the recursive resolver <em>where to go next</em><br />✔ They distribute DNS responsibility across multiple servers<br />✔ They enable redundancy — if one NS is down, others answer</p>
<p>So when a resolver asks the root:</p>
<pre><code class="lang-javascript">What is the A record <span class="hljs-keyword">for</span> google.com?
</code></pre>
<p>The root says:</p>
<pre><code class="lang-javascript">Ask these TLD .com servers → they know where google.com’s authoritative servers are.
</code></pre>
<p>Then the resolver goes to <code>.com</code> and asks:</p>
<pre><code class="lang-javascript">Where are the NS <span class="hljs-keyword">for</span> google.com?
</code></pre>
<p>And so on.</p>
<hr />
<h2 id="heading-6-how-recursive-resolvers-use-this">🔄 6. How Recursive Resolvers Use This</h2>
<p>A <strong>recursive resolver</strong> (like your ISP DNS or 8.8.8.8) takes your query and does the entire journey through DNS hierarchy <em>for you</em>.</p>
<p>Recursive behavior:</p>
<ol>
<li><p>Receive query from client</p>
</li>
<li><p>Check cache for an existing answer</p>
</li>
<li><p>If not cached, ask root → TLD → authoritative</p>
</li>
<li><p>Return final answer to client</p>
</li>
<li><p>Cache it for faster future responses</p>
</li>
</ol>
<p>Clients don’t need to know about NS, TLD, or root servers — resolvers handle that.</p>
<hr />
<h2 id="heading-7-connecting-dig-googlecomhttpgooglecom-to-real-browser-requests">🔗 7. Connecting <code>dig</code> <a target="_blank" href="http://google.com"><code>google.com</code></a> to Real Browser Requests</h2>
<p>When you type a URL in your browser:</p>
<pre><code class="lang-javascript">https:<span class="hljs-comment">//www.google.com</span>
</code></pre>
<p>Your browser first needs an <strong>IP address</strong> for <a target="_blank" href="http://www.google.com"><code>www.google.com</code></a>.</p>
<p>So it:</p>
<ol>
<li><p>Queries your <strong>recursive resolver</strong> (often provided by router/ISP)</p>
</li>
<li><p>Resolver returns <code>142.250.190.78</code></p>
</li>
<li><p>Browser connects to that IP on port 443 (HTTPS)</p>
</li>
<li><p>TLS handshake and HTTP request happen next</p>
</li>
</ol>
<p>In short:</p>
<pre><code class="lang-javascript">Browser → DNS lookup (to get IP) → Connect to IP → Load web page
</code></pre>
<p>Without the DNS step, the browser wouldn’t know where to connect.</p>
<hr />
<h2 id="heading-summary">🧩 Summary</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Concept</td><td>Real-World Role</td></tr>
</thead>
<tbody>
<tr>
<td>DNS</td><td>Internet phonebook</td></tr>
<tr>
<td>dig</td><td>Tool to inspect DNS answers</td></tr>
<tr>
<td>NS records</td><td>Tell you who’s authoritative</td></tr>
<tr>
<td>Recursive resolver</td><td>Does all lookup heavy lifting</td></tr>
<tr>
<td>Browser</td><td>Uses DNS answer to connect to a server</td></tr>
</tbody>
</table>
</div>]]></content:encoded></item><item><title><![CDATA[Getting Started with cURL]]></title><description><![CDATA[1. What Is cURL (in Very Simple Terms)
cURL (short for “Client URL”) is a free and open-source command-line tool that lets you send and receive data from a server using a URL. In simple words, it allows your terminal (command line) to talk to website...]]></description><link>https://birendra.site/getting-started-with-curl</link><guid isPermaLink="true">https://birendra.site/getting-started-with-curl</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sun, 25 Jan 2026 10:20:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769336410722/46587fc0-ddf1-4138-993c-ab886258349e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-1-what-is-curl-in-very-simple-terms"><strong>1. What Is cURL (in Very Simple Terms)</strong></h2>
<p>cURL (short for “Client URL”) is a <strong>free and open-source command-line tool</strong> that lets you <strong>send and receive data from a server using a URL</strong>. In simple words, it allows your terminal (command line) to talk to websites and services over the Internet. You type the command, and it transfers data for you.</p>
<p>Unlike using a browser, cURL works without a graphical interface and is ideal for developers when interacting with online services.</p>
<hr />
<h2 id="heading-2-why-programmers-need-curl"><strong>2. Why Programmers Need cURL</strong></h2>
<p>Programmers use cURL because it is:</p>
<ul>
<li><p><strong>Fast and lightweight:</strong> It runs in the terminal and does not need a heavy application.</p>
</li>
<li><p><strong>Versatile:</strong> It supports many protocols like HTTP and HTTPS, so you can fetch pages or APIs.</p>
</li>
<li><p><strong>Great for testing and debugging:</strong> Many API documentation examples use cURL to show how to make requests.</p>
</li>
<li><p><strong>Scriptable:</strong> You can automate tasks like downloading files or running API tests using scripts.</p>
</li>
</ul>
<p>In short, when programmers need to <strong>check how a server responds</strong> or <strong>communicate with online services without a browser</strong>, they use cURL.</p>
<hr />
<h2 id="heading-3-making-your-first-request-using-curl"><strong>3. Making Your First Request Using cURL</strong></h2>
<p>To use cURL, open your terminal (Mac/Linux) or Command Prompt/PowerShell (Windows):</p>
<pre><code class="lang-javascript">curl https:<span class="hljs-comment">//example.com</span>
</code></pre>
<p>This command will fetch data from <a target="_blank" href="http://example.com">example.com</a> and print the result right in your terminal.</p>
<p>For APIs, most of the time you will use cURL with additional options like:</p>
<pre><code class="lang-javascript">curl -X GET https:<span class="hljs-comment">//api.example.com/data</span>
</code></pre>
<ul>
<li><code>-X GET</code> tells cURL to use the GET method (read data).</li>
</ul>
<p>This way, cURL helps you send requests to services and see the response.</p>
<hr />
<h2 id="heading-4-understanding-request-and-response"><strong>4. Understanding Request and Response</strong></h2>
<p>When you send a request with cURL:</p>
<ol>
<li><p>You specify the <strong>URL</strong> you want to reach.</p>
</li>
<li><p>The server receives that request.</p>
</li>
<li><p>The server sends back a <strong>response</strong>, such as HTML, JSON, or plain text.</p>
</li>
</ol>
<p>cURL prints that response in your terminal so you can inspect it. For example:</p>
<pre><code class="lang-javascript">curl https:<span class="hljs-comment">//api.example.com/user</span>
</code></pre>
<p>Might return:</p>
<pre><code class="lang-javascript">{<span class="hljs-string">"id"</span>:<span class="hljs-number">1</span>,<span class="hljs-string">"name"</span>:<span class="hljs-string">"Amit Kumar"</span>}
</code></pre>
<p>This shows how the data is returned from the server.</p>
<hr />
<h2 id="heading-5-using-curl-to-talk-to-apis"><strong>5. Using cURL to Talk to APIs</strong></h2>
<p>APIs (Application Programming Interfaces) are services that let programs communicate with each other. cURL is commonly used to:</p>
<ul>
<li><p><strong>Get data</strong> from an API: <code>curl -X GET</code> <a target="_blank" href="https://api.example.com/users"><code>https://api.example.com/users</code></a></p>
</li>
<li><p><strong>Send data</strong> to an API (e.g., a POST request):</p>
<pre><code class="lang-javascript">  curl -X POST https:<span class="hljs-comment">//api.example.com/users \</span>
       -H <span class="hljs-string">"Content-Type: application/json"</span> \
       -d <span class="hljs-string">'{"name":"Ravi"}'</span>
</code></pre>
<p>  Here, <code>-d</code> sends JSON data to the server.</p>
</li>
</ul>
<p>This makes cURL a powerful tool for <strong>testing and automating API usage</strong>.</p>
<hr />
<h2 id="heading-6-common-mistakes-beginners-make-with-curl"><strong>6. Common Mistakes Beginners Make with cURL</strong></h2>
<p>Beginners often run into these issues:</p>
<ul>
<li><p><strong>Not using quotes around URLs with parameters</strong> — CLI may misinterpret special characters.</p>
</li>
<li><p><strong>Not specifying the correct request method</strong> (<code>GET</code>, <code>POST</code>, <code>PUT</code>, etc.).</p>
</li>
<li><p><strong>Forgetting to add headers</strong> when needed (<code>-H "Content-Type: application/json"</code>).</p>
</li>
<li><p><strong>Confusing response output with errors</strong> — Remember some flags (like <code>-i</code> or <code>-v</code>) help show headers and debugging info.</p>
</li>
</ul>
<p>Always start simple, see what output you get, and then add options one at a time.</p>
<hr />
<h2 id="heading-7-suggestions-for-learners"><strong>7. Suggestions for Learners</strong></h2>
<ul>
<li><p><strong>Learn by doing:</strong> Practice common requests like GET and POST.</p>
</li>
<li><p><strong>Use official API docs:</strong> Most REST API guides include cURL examples.</p>
</li>
<li><p><strong>Try tools like Postman after cURL:</strong> cURL helps you understand what’s happening behind the scenes.</p>
</li>
<li><p><strong>Explore flags:</strong> Options like <code>-I</code> (headers), <code>-L</code> (follow redirects), and <code>-O</code> (save file) make cURL more powerful.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[What is DNS, and DNS Record Types  | How DNS works]]></title><description><![CDATA[What is DNS?
The Domain Name System is the phonebook of the Internet. Users access information online through domain names such as indiatimes.com or epson.com. A web browser communicates using the Internet Protocol address. DNS translates the domain ...]]></description><link>https://birendra.site/what-is-dns-and-dns-record-types-how-dns-works</link><guid isPermaLink="true">https://birendra.site/what-is-dns-and-dns-record-types-how-dns-works</guid><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Thu, 22 Jan 2026 07:25:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769065536653/4bd3407e-d476-4280-83ee-018b97dc3bc7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-dns">What is DNS?</h2>
<p>The Domain Name System is the phonebook of the Internet. Users access information online through domain names such as indiatimes.com or epson.com. A web browser communicates using the Internet Protocol address. DNS translates the domain name into an IP address, so the browser can load the internet resource.</p>
<p><em>You type "</em><a target="_blank" href="http://google.com"><em>google.com</em></a><em>" in your browser and it loads. But how does your computer know where Google actually is?</em></p>
<h3 id="heading-how-does-dns-work"><strong>How does DNS work?</strong></h3>
<p>The DNS resolution process converts a hostname into a computer-friendly IP address. An IP address is give to each device on the is used to find the appropriate internet device, like a street address, between what a user types into their web browser and the machine-friendly address necessary to locate the example.com webpage.</p>
<p>To understand the process of DNS resolution, it’s important to learn about the different hardware components a DNS query must pass through. For the web browser, the DNS lookup occurs “behind the scenes” and requires no interaction from the user’s computer apart from the request</p>
<h2 id="heading-what-are-dns-records"><strong>What Are DNS Records?</strong></h2>
<p>DNS records answer one question: <strong>"Where should this request go?"</strong></p>
<p>Different record types give different answers:</p>
<ul>
<li><p>"Here's the IP address" (A Record)</p>
</li>
<li><p>"Go ask that other domain" (CNAME Record)</p>
</li>
<li><p>"Send email here" (MX Record)</p>
</li>
<li><p>"These servers control this domain" (NS Record)</p>
</li>
</ul>
<h2 id="heading-1-a-record-the-basic-address"><strong>1. A Record: The Basic Address</strong></h2>
<p><strong>What it does:</strong> Maps a domain name to an IP address.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-javascript">example.com  →  <span class="hljs-number">192.168</span><span class="hljs-number">.1</span><span class="hljs-number">.1</span>
</code></pre>
<p>When someone types "example.com", DNS says "go to 192.168.1.1"</p>
<p><strong>Real use:</strong> You point your domain to your server's IP address.</p>
<p><strong>Key point:</strong> A records work with IPv4 addresses (like 192.168.1.1).</p>
<h2 id="heading-2-cname-record-the-alias"><strong>2. CNAME Record: The Alias</strong></h2>
<p><strong>What it does:</strong> Points one domain name to another domain name.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-javascript">www.example.com  →  example.com
blog.example.com  →  example.com
</code></pre>
<p><strong>Real use:</strong></p>
<ul>
<li><p>Make <a target="_blank" href="http://www.yoursite.com/">www.yoursite.com</a> and yoursite.com go to the same place</p>
</li>
<li><p>Use blog.yoursite.com but host on Medium</p>
</li>
<li><p>Route traffic through a CDN</p>
</li>
</ul>
<p><strong>Key point:</strong> CNAME redirects to another domain, which then has an A record pointing to the IP.</p>
<h3 id="heading-a-record-vs-cname"><strong>A Record vs CNAME</strong></h3>
<p><strong>A Record:</strong> Points directly to an IP</p>
<pre><code class="lang-javascript">example.com  →  <span class="hljs-number">192.168</span><span class="hljs-number">.1</span><span class="hljs-number">.1</span>
</code></pre>
<p><strong>CNAME:</strong> Points to another domain</p>
<pre><code class="lang-javascript">www.example.com  →  example.com  →  <span class="hljs-number">192.168</span><span class="hljs-number">.1</span><span class="hljs-number">.1</span>
</code></pre>
<p><strong>Important:</strong> You can't use CNAME for your root domain (example.com). Only subdomains can be CNAMEs.</p>
<h2 id="heading-3-mx-record-email-routing"><strong>3. MX Record: Email Routing</strong></h2>
<p><strong>What it does:</strong> Tells email servers where to send emails for your domain.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-javascript">example.com  →  mail.example.com  (priority: <span class="hljs-number">10</span>)
example.com  →  backup-mail.example.com  (priority: <span class="hljs-number">20</span>)
</code></pre>
<p><strong>How it works:</strong></p>
<ol>
<li><p>Someone emails <a target="_blank" href="mailto:you@example.com">you@example.com</a></p>
</li>
<li><p>Their email server checks MX records</p>
</li>
<li><p>Email goes to the server with lowest priority number</p>
</li>
</ol>
<p><strong>Real use:</strong> Point your domain's email to Gmail or Outlook servers.</p>
<p><strong>Key point:</strong> Lower priority number = tried first. If it fails, tries the next one.</p>
<h2 id="heading-4-ns-record-whos-in-control"><strong>4. NS Record: Who's in Control</strong></h2>
<p><strong>What it does:</strong> Says which DNS servers control your domain.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-javascript">example.com  →  ns1.cloudflare.com
example.com  →  ns2.cloudflare.com
</code></pre>
<p><strong>Real use:</strong> You buy a domain from GoDaddy but use Cloudflare for DNS. You change NS records to Cloudflare's servers.</p>
<p><strong>Key point:</strong> NS records determine who manages all your other DNS records.</p>
<h3 id="heading-ns-vs-mx-the-difference"><strong>NS vs MX: The Difference</strong></h3>
<p><strong>NS Record:</strong> Which servers control ALL DNS for this domain</p>
<p><strong>MX Record:</strong> Which servers handle EMAIL only</p>
<h2 id="heading-how-they-work-together"><strong>How They Work Together</strong></h2>
<p>Real example for company.com:</p>
<pre><code class="lang-javascript">A Record:
company.com  →  <span class="hljs-number">93.184</span><span class="hljs-number">.216</span><span class="hljs-number">.34</span>

CNAME Records:
www.company.com  →  company.com
blog.company.com  →  company.com

MX Records:
company.com  →  smtp.google.com  (priority: <span class="hljs-number">10</span>)

NS Records:
company.com  →  ns1.cloudflare.com
</code></pre>
<p><strong>What this means:</strong></p>
<ul>
<li><p>Main site is at that IP</p>
</li>
<li><p>www and blog point to the same server</p>
</li>
<li><p>Emails go to Google</p>
</li>
<li><p>Cloudflare manages the DNS</p>
</li>
</ul>
<h3 id="heading-complete-flow-for-wwwcompanycomhttpwwwcompanycom"><strong>Complete Flow for</strong> <a target="_blank" href="http://www.company.com/"><strong>www.company.com</strong></a></h3>
<ol>
<li><p>Browser asks: "What's <a target="_blank" href="http://www.company.com/?">www.company.com?</a>"</p>
</li>
<li><p>DNS checks NS records: "Ask Cloudflare"</p>
</li>
<li><p>Cloudflare checks CNAME: "It's an alias for company.com"</p>
</li>
<li><p>Cloudflare checks A record: "That's 93.184.216.34"</p>
</li>
<li><p>Browser connects to that IP</p>
</li>
</ol>
<p>Happens in milliseconds!</p>
<h2 id="heading-common-setups"><strong>Common Setups</strong></h2>
<p><strong>Simple Website:</strong></p>
<pre><code class="lang-javascript">yoursite.com      →  <span class="hljs-number">192.168</span><span class="hljs-number">.1</span><span class="hljs-number">.1</span>  (A)
www.yoursite.com  →  yoursite.com  (CNAME)
</code></pre>
<p><strong>Website + Email:</strong></p>
<pre><code class="lang-javascript">yoursite.com      →  <span class="hljs-number">192.168</span><span class="hljs-number">.1</span><span class="hljs-number">.1</span>  (A)
www.yoursite.com  →  yoursite.com  (CNAME)
yoursite.com      →  mail.google.com  (MX)
</code></pre>
<p><strong>Using CDN:</strong></p>
<pre><code class="lang-javascript">yoursite.com      →  <span class="hljs-number">192.168</span><span class="hljs-number">.1</span><span class="hljs-number">.1</span>  (A)
www.yoursite.com  →  yoursite.cdn.com  (CNAME)
yoursite.com      →  ns1.cloudflare.com  (NS)
</code></pre>
<h2 id="heading-why-developers-need-this"><strong>Why Developers Need This</strong></h2>
<p>You'll use DNS records for:</p>
<ul>
<li><p><strong>Deploying sites:</strong> Point domain to server IP</p>
</li>
<li><p><strong>Subdomains:</strong> Create api.yoursite.com or dev.yoursite.com</p>
</li>
<li><p><strong>Email setup:</strong> Configure business email</p>
</li>
<li><p><strong>CDNs:</strong> Route through Cloudflare or AWS</p>
</li>
<li><p><strong>Debugging:</strong> Check DNS when sites don't load</p>
</li>
</ul>
<p><strong>Interview tip:</strong> Know A vs CNAME and what MX/NS records do.</p>
<h2 id="heading-quick-summary"><strong>Quick Summary</strong></h2>
<ul>
<li><p><strong>A Record:</strong> Domain → IP address</p>
</li>
<li><p><strong>CNAME Record:</strong> Domain → Another domain (alias)</p>
</li>
<li><p><strong>MX Record:</strong> Where emails go (with priority)</p>
</li>
<li><p><strong>NS Record:</strong> Which servers control DNS</p>
</li>
</ul>
<p><strong>Remember:</strong></p>
<ul>
<li><p>A points to IPs, CNAME points to domains</p>
</li>
<li><p>MX is for email, NS is for DNS control</p>
</li>
<li><p>Lower MX priority number = higher priority</p>
</li>
<li><p>Can't use CNAME on root domain</p>
</li>
</ul>
<p>Understanding DNS helps you deploy sites, fix issues, and ace interviews.</p>
]]></content:encoded></item><item><title><![CDATA[Why Version Control Exists: The Pendrive Problem Every Developer Faced]]></title><description><![CDATA[If you're new to programming, you've probably heard developers say things like "Just push it to GitHub" or "Check the commit history." At first, it might feel unnecessary or confusing.
So let's answer a simple question:
Why does version control exist...]]></description><link>https://birendra.site/why-version-control-exists-the-pendrive-problem-every-developer-faced</link><guid isPermaLink="true">https://birendra.site/why-version-control-exists-the-pendrive-problem-every-developer-faced</guid><category><![CDATA[#Git #GitHub #versioncontrol #collaboration #softwaredevelopment #sourcecode #repository #commit #branch #merge #pullrequest #fork #workflow #issues #bugtracking #continuousintegration #deployment #devops #opensource #coding]]></category><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sun, 04 Jan 2026 14:12:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769067186518/09b317fc-1b41-461c-8af2-da6b836c43a8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you're new to programming, you've probably heard developers say things like "Just push it to GitHub" or "Check the commit history." At first, it might feel unnecessary or confusing.</p>
<p>So let's answer a simple question:</p>
<p><strong>Why does version control exist at all?</strong></p>
<p>To understand that, we need to go back to how developers worked before tools like Git existed, and the answer starts with pendrives, emails, and folders named <code>final_final</code>.</p>
<h3 id="heading-why-version-control-exists"><strong>Why Version Control Exists</strong></h3>
<p>Version control is a system that tracks changes in your code over time.</p>
<p>It helps developers:</p>
<ul>
<li><p>Save their work safely</p>
</li>
<li><p>Work together without breaking things</p>
</li>
<li><p>Go back to older versions when something goes wrong</p>
</li>
</ul>
<p>But version control wasn't created because developers wanted fancy tools. It was created because <strong>the old ways of sharing code were painful and risky</strong>.</p>
<p>Before version control systems, many developers followed a workflow like this:</p>
<ol>
<li><p>Write code on your computer</p>
</li>
<li><p>Copy the project to a pendrive</p>
</li>
<li><p>Give it to a teammate or email it</p>
</li>
<li><p>Hope nothing breaks</p>
</li>
</ol>
<p>Soon, the project folder looked like this:</p>
<pre><code class="lang-javascript">📁 project
📁 project_final
📁 project_final_v2
📁 project_latest
📁 project_latest_final
</code></pre>
<p>No one knew:</p>
<ul>
<li><p>Which version was correct</p>
</li>
<li><p>Which changes were new</p>
</li>
<li><p>What had been overwritten</p>
</li>
</ul>
<p>This method worked only when <strong>one person</strong> was working. The moment a team got involved, things started falling apart.</p>
<h2 id="heading-problems-developers-faced-before-version-control-systems"><strong>Problems Developers Faced Before Version Control Systems</strong></h2>
<h3 id="heading-1-multiple-developers-overwriting-each-others-code"><strong>1. Multiple Developers Overwriting Each Other's Code</strong></h3>
<p>Imagine two developers working on the same file.</p>
<ul>
<li><p><strong>Developer A</strong> edits the file and saves it</p>
</li>
<li><p><strong>Developer B</strong> edits the same file and saves it later</p>
</li>
</ul>
<p><strong>Whoever saves last wins.</strong></p>
<p>The other person's work is completely lost.</p>
<p>This was a nightmare for collaboration.</p>
<h3 id="heading-2-file-versions-getting-lost-over-time"><strong>2. File Versions Getting Lost Over Time</strong></h3>
<p>When something broke, developers had no easy way to:</p>
<ul>
<li><p>Go back to a working version</p>
</li>
<li><p>See what changed</p>
</li>
<li><p>Fix the issue quickly</p>
</li>
</ul>
<p>Instead, they relied on file names and memory.</p>
<pre><code class="lang-javascript">Day <span class="hljs-number">1</span> → project
Day <span class="hljs-number">3</span> → project_final
Day <span class="hljs-number">5</span> → project_final_v2
Day <span class="hljs-number">7</span> → project_latest
❓ Which one actually works?
</code></pre>
<p>There was no real history, just guesses.</p>
<h3 id="heading-3-no-record-of-who-changed-what-or-why"><strong>3. No Record of Who Changed What (or Why)</strong></h3>
<p>When bugs appeared, developers asked questions like:</p>
<ul>
<li><p>Who changed this file?</p>
</li>
<li><p>Why was this logic added?</p>
</li>
<li><p>When did this break?</p>
</li>
</ul>
<p>And most of the time <strong>"there were no answers"</strong>.</p>
<h3 id="heading-4-fear-of-breaking-the-project"><strong>4. Fear of Breaking the Project</strong></h3>
<p>Because there was no safety net:</p>
<ul>
<li><p>Developers avoided experimenting</p>
</li>
<li><p>New ideas felt risky</p>
</li>
<li><p>One mistake could ruin everything</p>
</li>
</ul>
<p>This slowed down learning and innovation.</p>
<h3 id="heading-why-the-pendrive-model-failed-for-teams"><strong>Why the Pendrive Model Failed for Teams</strong></h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767535584398/33d353f1-de6e-428a-96d7-667c4f0dedc2.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>5–10 developers</p>
</li>
<li><p>Working from different places</p>
</li>
<li><p>Changing the same code every day</p>
</li>
</ul>
<p>Pendrives, emails, and "final" folders simply couldn't scale.</p>
<p>Teams needed:</p>
<ul>
<li><p>A <strong>single source of truth</strong></p>
</li>
<li><p>A <strong>complete history</strong> of changes</p>
</li>
<li><p>A way to <strong>work together without conflict</strong></p>
</li>
</ul>
<p>This is where version control changed everything.</p>
<h3 id="heading-how-version-control-solved-these-problems"><strong>How Version Control Solved These Problems</strong></h3>
<p>Version control systems introduced a better way:</p>
<p>✅ <strong>Every change is saved as a version</strong></p>
<p>✅ <strong>You can see who made a change and why</strong></p>
<p>✅ <strong>You can go back in time if something breaks</strong></p>
<p>✅ <strong>Multiple developers can work at the same time</strong></p>
<p>✅ <strong>Experimenting becomes safe</strong></p>
<p>Instead of guessing, developers gained <strong>clarity and confidence</strong>.</p>
<h3 id="heading-why-version-control-is-mandatory-today"><strong>Why Version Control Is Mandatory Today</strong></h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767535620128/4c5c6907-7a12-4185-8973-e56440a583dc.png" alt class="image--center mx-auto" /></p>
<p>Today, tools like <strong>Git</strong> and <strong>GitHub</strong> are basic skills for developers.</p>
<p>Without version control:</p>
<ul>
<li><p>Team collaboration would be chaotic</p>
</li>
<li><p>Bugs would be harder to fix</p>
</li>
<li><p>Modern software development wouldn't be possible</p>
</li>
</ul>
<p>Version control exists because humans forget, overwrite, and make mistakes, and <strong>software needs a system that doesn't</strong>.</p>
<h3 id="heading-final-thoughts"><strong>Final Thoughts</strong></h3>
<p>The pendrive problem wasn't really about storage. It was about:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767535714303/cf86f616-d995-48de-9af8-28393be79cb8.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p><strong>Lost work</strong></p>
</li>
<li><p><strong>Broken collaboration</strong></p>
</li>
<li><p><strong>No history</strong></p>
</li>
<li><p><strong>No trust in the process</strong></p>
</li>
</ul>
<p>Version control solved all of that.</p>
<p>So when you learn Git, remember: <strong>you're not just learning a tool</strong>.</p>
<p>You're learning the solution to a problem every developer once struggled with.</p>
<h3 id="heading-remember-this"><strong>Remember This?</strong></h3>
<pre><code class="lang-javascript">📁 project
📁 project_final
📁 project_final_v2
📁 project_latest
📁 project_latest_final
</code></pre>
<p><strong>Those days are over.</strong> Welcome to version control. 🚀</p>
]]></content:encoded></item><item><title><![CDATA[Inside Git: How It Works and the Role of the .git Folder]]></title><description><![CDATA[Most developers use Git every day.
They run commands like git add, git commit, and git log—but very few truly understand what Git is doing internally.This article is about going one level deeper.
How Git Works
At its core, Git is a content-addressabl...]]></description><link>https://birendra.site/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://birendra.site/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><category><![CDATA[Git]]></category><category><![CDATA[github-actions]]></category><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sun, 04 Jan 2026 14:02:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769067039957/a047474c-f624-44e6-855d-502a51d1b2b5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Most developers use Git every day.</p>
<p>They run commands like <code>git add</code>, <code>git commit</code>, and <code>git log</code>—but very few truly understand <strong>what Git is doing internally</strong>.<br />This article is about going <strong>one level deeper</strong>.</p>
<h2 id="heading-how-git-works">How Git Works</h2>
<p>At its core, <strong>Git is a content-addressable database</strong>.</p>
<p>Instead of thinking:</p>
<blockquote>
<p>“Git saves files”</p>
</blockquote>
<p>Think this instead:</p>
<blockquote>
<p><strong>Git stores snapshots of content, linked together by cryptographic hashes</strong></p>
</blockquote>
<p>Every piece of data in Git:</p>
<ul>
<li><p>Is stored once</p>
</li>
<li><p>Is immutable</p>
</li>
<li><p>Is referenced by a hash (SHA-1 / SHA-256)</p>
</li>
</ul>
<p>Git never tracks “changes” directly.<br />It tracks <strong>objects</strong> that represent complete states.</p>
<h2 id="heading-what-is-the-git-folder-and-why-does-it-exist">What Is the <code>.git</code> Folder and Why Does It Exist?</h2>
<p>When you run:</p>
<pre><code class="lang-javascript">git init
</code></pre>
<p>Git creates a hidden directory called <code>.git</code>.</p>
<p>This folder is the <strong>entire Git repository</strong>.</p>
<p>Your project files are just the <em>working copy</em>.<br />The <strong>real Git database lives inside</strong> <code>.git</code>.</p>
<blockquote>
<p>If you delete <code>.git</code>, your project becomes a normal folder again.</p>
</blockquote>
<h3 id="heading-structure-of-the-git-directory">Structure of the <code>.git</code> Directory</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767534464004/1680e976-6d38-43b3-8aa1-f78cdb3dfb81.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-key-components">Key components</h3>
<ul>
<li><p><strong>HEAD</strong><br />  Points to the current branch/commit</p>
</li>
<li><p><strong>objects/</strong><br />  Stores all Git objects (blobs, trees, commits)</p>
</li>
<li><p><strong>refs/</strong><br />  Stores branch and tag references</p>
</li>
<li><p><strong>index</strong><br />  Represents the <strong>staging area</strong></p>
</li>
<li><p><strong>config</strong><br />  Repository-level configuration</p>
</li>
</ul>
<p>📌 <strong>Everything Git knows about your project is stored here.</strong></p>
<h3 id="heading-git-objects-blob-tree-commit">Git Objects: Blob, Tree, Commit</h3>
<p>Git stores only <strong>three main object types</strong>.</p>
<p>Understanding these removes 80% of Git confusion.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767534877917/f5152db2-1331-4cee-bd05-593986b8d343.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-1-blob-file-content">1. Blob (File Content)</h3>
<p>A <strong>blob</strong> stores:</p>
<ul>
<li><p>The <em>contents</em> of a file</p>
</li>
<li><p>Nothing else (no filename, no permissions)</p>
</li>
</ul>
<p>If two files have identical content → Git stores <strong>one blob</strong>.</p>
<h3 id="heading-2-tree-directory-structure">2. Tree (Directory Structure)</h3>
<p>A <strong>tree</strong> represents:</p>
<ul>
<li><p>A directory</p>
</li>
<li><p>Filenames</p>
</li>
<li><p>Permissions</p>
</li>
<li><p>Pointers to blobs or other trees</p>
</li>
</ul>
<p>Trees define <strong>project structure</strong>.</p>
<h3 id="heading-3-commit-snapshot-metadata">3. Commit (Snapshot + Metadata)</h3>
<p>A <strong>commit</strong> contains:</p>
<ul>
<li><p>A pointer to a <strong>root tree</strong></p>
</li>
<li><p>Parent commit(s)</p>
</li>
<li><p>Author</p>
</li>
<li><p>Timestamp</p>
</li>
<li><p>Commit message</p>
</li>
</ul>
<p>A commit does <strong>not store files directly</strong>.</p>
<p>It points to a tree, which points to blobs.</p>
<h3 id="heading-relationship-between-commits-trees-and-blobs">Relationship Between Commits, Trees, and Blobs</h3>
<h3 id="heading-think-of-it-like-this">Think of it like this:</h3>
<pre><code class="lang-javascript">Commit
 └── Tree (root directory)
     ├── Blob (file1)
     ├── Blob (file2)
     └── Tree (subdirectory)
         └── Blob (file3)
</code></pre>
<p>Each object is:</p>
<ul>
<li><p>Immutable</p>
</li>
<li><p>Identified by a hash</p>
</li>
<li><p>Reused if content does not change</p>
</li>
</ul>
<hr />
<h2 id="heading-how-git-tracks-changes-the-truth">How Git Tracks Changes (The Truth)</h2>
<p>Git does <strong>not</strong> store diffs.</p>
<p>Instead:</p>
<ul>
<li><p>Each commit is a <strong>complete snapshot</strong></p>
</li>
<li><p>Git optimizes storage by reusing unchanged objects</p>
</li>
</ul>
<p>If a file does not change:</p>
<ul>
<li><p>Its blob hash remains the same</p>
</li>
<li><p>Git simply references the existing blob</p>
</li>
</ul>
<p>This is why Git is both <strong>fast and efficient</strong>.</p>
<hr />
<h2 id="heading-what-happens-internally-during-git-add">What Happens Internally During <code>git add</code></h2>
<p><img src="https://miro.medium.com/0%2Aw_iFdtySLrVj4ecD.jpg" alt="https://miro.medium.com/0%2Aw_iFdtySLrVj4ecD.jpg" /></p>
<p><img src="https://phoenixnap.com/kb/wp-content/uploads/2021/09/git-workflow.png" alt="https://phoenixnap.com/kb/wp-content/uploads/2021/09/git-workflow.png" /></p>
<h3 id="heading-step-by-step">Step-by-step:</h3>
<ol>
<li><p>You modify a file in the working directory</p>
</li>
<li><p><code>git add file.txt</code> is executed</p>
</li>
<li><p>Git:</p>
<ul>
<li><p>Reads file content</p>
</li>
<li><p>Creates a <strong>blob object</strong></p>
</li>
<li><p>Stores it in <code>.git/objects</code></p>
</li>
</ul>
</li>
<li><p>Updates the <strong>index (staging area)</strong> to reference the blob</p>
</li>
</ol>
<p>📌 No commit yet.<br />📌 The change is prepared, not saved permanently.<br />What Happens Internally During <code>git commit</code></p>
<p><img src="https://images.openai.com/thumbnails/url/8SeE63icu5mVUVJSUGylr5-al1xUWVCSmqJbkpRnoJdeXJJYkpmsl5yfq5-Zm5ieWmxfaAuUsXL0S7F0Tw5yKi90C_IONw4ozy8ONLH0znSsdLXMSjJJcgqtCkhOLUlODMs0tXB1MyoqiDBOLi2qVCsGAIDhJp8" alt="https://i.sstatic.net/MgaV9.png" /></p>
<p><img src="https://miro.medium.com/1%2ALa9tFzHMf2OIhzyhIcs20Q.png" alt="https://miro.medium.com/1%2ALa9tFzHMf2OIhzyhIcs20Q.png" /></p>
<h3 id="heading-step-by-step-1">Step-by-step:</h3>
<ol>
<li><p>Git reads the staging area (index)</p>
</li>
<li><p>Creates a <strong>tree object</strong> from staged files</p>
</li>
<li><p>Creates a <strong>commit object</strong> that:</p>
<ul>
<li><p>Points to the tree</p>
</li>
<li><p>Points to the previous commit</p>
</li>
</ul>
</li>
<li><p>Updates branch reference (e.g., <code>main</code>)</p>
</li>
<li><p>Moves <code>HEAD</code> to the new commit</p>
</li>
</ol>
<p>📌 Now the snapshot is permanent.</p>
<hr />
<h2 id="heading-why-git-uses-hashes-integrity-amp-trust">Why Git Uses Hashes (Integrity &amp; Trust)</h2>
<p>Every Git object is named by a <strong>cryptographic hash</strong>.</p>
<p>Example:</p>
<pre><code class="lang-javascript">f374df2a6b...
</code></pre>
<p>This ensures:</p>
<ul>
<li><p>Data integrity (no silent corruption)</p>
</li>
<li><p>Content verification</p>
</li>
<li><p>Tamper detection</p>
</li>
</ul>
<p>If content changes → hash changes → object identity changes.</p>
<blockquote>
<p>Git literally cannot lie about history without breaking hashes.</p>
</blockquote>
<p>This is why Git is trusted for:</p>
<ul>
<li><p>Open source</p>
</li>
<li><p>Security-sensitive projects</p>
</li>
<li><p>Distributed collaboration</p>
</li>
</ul>
<hr />
<h2 id="heading-mental-model-summary-remember-this">Mental Model Summary (Remember This)</h2>
<p>Instead of memorizing commands, remember this flow:</p>
<pre><code class="lang-javascript">Files → Blobs → Trees → Commits → History
</code></pre>
<p>And this truth:</p>
<blockquote>
<p><strong>Git is a database of snapshots, not a diff tracker.</strong></p>
</blockquote>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>Understanding Git internals:</p>
<ul>
<li><p>Makes you confident during conflicts</p>
</li>
<li><p>Helps you debug weird Git behavior</p>
</li>
<li><p>Separates senior developers from beginners</p>
</li>
<li><p>Makes Git feel logical, not magical</p>
</li>
</ul>
<p>Once this mental model clicks, Git becomes <strong>predictable</strong>.</p>
]]></content:encoded></item><item><title><![CDATA[Git for Beginners: Basics and Essential Commands]]></title><description><![CDATA[If you are starting your journey as a developer, you will hear the word Git everywhere.
Job descriptions mention it.Open-source projects require it.And almost every development team uses it daily.
But what exactly is Git? And why is it so important?
...]]></description><link>https://birendra.site/git-for-beginners-basics-and-essential-commands</link><guid isPermaLink="true">https://birendra.site/git-for-beginners-basics-and-essential-commands</guid><category><![CDATA[Git]]></category><category><![CDATA[gitbash]]></category><category><![CDATA[#Gitbasics]]></category><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sun, 04 Jan 2026 13:00:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769066931599/9532a284-24de-41c7-9789-30017f301cd5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you are starting your journey as a developer, you will hear the word <strong>Git</strong> everywhere.</p>
<p>Job descriptions mention it.<br />Open-source projects require it.<br />And almost every development team uses it daily.</p>
<p>But what exactly is Git? And why is it so important?</p>
<p>Git helps you manage your code changes safely, work together smoothly, and develop software in a professional way.</p>
<p>This article explains <strong>Git from scratch</strong>, in simple language, with beginner-friendly examples and the most commonly used commands.</p>
<h2 id="heading-what-is-git">What Is Git?</h2>
<p><strong>Git is a version control system.</strong></p>
<p>In simple words, Git helps you <strong>track changes in your code over time</strong>.</p>
<p>Think of Git like a <strong>time machine for your project</strong>:</p>
<ul>
<li><p>You can see what changed</p>
</li>
<li><p>You can go back to older versions</p>
</li>
<li><p>You can work with others without breaking their code</p>
</li>
</ul>
<p>Git was created to solve one big problem:</p>
<blockquote>
<p><em>How do developers safely manage changes in large projects?</em></p>
</blockquote>
<h2 id="heading-why-git-is-used">Why Git Is Used</h2>
<p>Git is used because it <strong>solves real problems developers face while building software</strong>, especially when projects grow or multiple people work together.</p>
<p>Below are the core reasons Git is essential in modern development.</p>
<h3 id="heading-1-version-control-track-changes-safely">1. Version Control (Track Changes Safely)</h3>
<p>Git keeps a complete history of your project. Every change is recorded. You can see who changed what and when. You can go back to any previous version.</p>
<p><mark>👉 If something breaks, Git lets you rollback safely.</mark></p>
<h3 id="heading-2-collaboration-without-others">2. Collaboration Without Others</h3>
<p>In real projects, many developers work on the same codebase.</p>
<p><strong>Git allows:</strong></p>
<ul>
<li><p>Multiple people work simultaneously</p>
</li>
<li><p>Merging work without overwriting others’ code</p>
</li>
<li><p>Resolving conflicts in a controlled way</p>
</li>
</ul>
<p><mark>👉 Without Git, teamwork becomes messy and error-prone.</mark></p>
<h3 id="heading-3-experiment-without-fear-branches">3. Experiment Without Fear (Branches)</h3>
<p>Git allows you to create <strong>branches</strong>.</p>
<ul>
<li><p>Try new features</p>
</li>
<li><p>Test ideas</p>
</li>
<li><p>Fix bugs separately</p>
</li>
</ul>
<p><mark>If something fails, you can simply discard the branch—</mark><strong><mark>main code stays safe</mark></strong><mark>.</mark></p>
<h3 id="heading-4-backup-amp-recovery">4. Backup &amp; Recovery</h3>
<p>Your code is not tied to one machine.</p>
<ul>
<li><p>Stored locally and remotely (GitHub, GitLab, etc.)</p>
</li>
<li><p>If your laptop crashes, your code is still safe</p>
</li>
<li><p>Deleted files can be recovered from the history</p>
</li>
</ul>
<p><mark>👉 Git acts like an automatic backup system.</mark></p>
<h3 id="heading-5-professional-workflow-standard">5. Professional Workflow Standard</h3>
<p>Almost every company uses Git.</p>
<ul>
<li><p>Code reviews</p>
</li>
<li><p>CI/CD pipelines</p>
</li>
<li><p>Deployment automation</p>
</li>
<li><p>Open-source contributions</p>
</li>
</ul>
<p><mark>👉 Knowing Git is </mark> <strong><mark>mandatory</mark></strong><mark>, not optional, for developer jobs.</mark></p>
<h3 id="heading-6-clear-project-history">6. Clear Project History</h3>
<p>Git creates a clean timeline of your project:</p>
<ul>
<li><p>Feature additions</p>
</li>
<li><p>Bug fixes</p>
</li>
<li><p>Improvements</p>
</li>
</ul>
<p><mark>This helps teams understand </mark> <strong><mark>why</mark></strong> <mark> a change was made, not just </mark> <strong><mark>what</mark></strong> <mark> changed.</mark></p>
<h2 id="heading-git-basics-and-core-terminologies">Git Basics and Core Terminologies</h2>
<p>Before commands, let's understand the basic concepts.</p>
<h3 id="heading-repository-repo"><strong>📁 Repository (Repo)</strong></h3>
<p>A <strong>repository</strong> is a folder that Git tracks.</p>
<p>It contains:</p>
<ul>
<li><p>Your project files</p>
</li>
<li><p>Git's history and metadata</p>
</li>
</ul>
<p>You create it using:</p>
<pre><code class="lang-javascript">git init
</code></pre>
<h3 id="heading-understanding-git-workflow"><strong>Understanding Git Workflow</strong></h3>
<p>Here's how Git organizes your work:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767529670587/2da8e710-eb59-40db-8413-0ea8689d602b.png" alt class="image--center mx-auto" /></p>
<p><strong>Three main areas:</strong></p>
<ol>
<li><p><strong>Working Directory</strong> - Where you make changes</p>
</li>
<li><p><strong>Staging Area</strong> - Where you prepare changes for commit</p>
</li>
<li><p><strong>Repository</strong> - Where Git permanently stores commits</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767531105989/f1d7c068-da14-4452-8087-9da0ef8d9800.png" alt class="image--center mx-auto" /></p>
<p><strong>Core Concepts of Commit History</strong></p>
<ul>
<li><p><strong>Snapshot-Based:</strong> Commits are snapshots of the entire project, not just file differences.</p>
</li>
<li><p><strong>Parent References:</strong> Each commit references its immediate predecessor (parent).</p>
</li>
<li><p><code>HEAD</code> Pointer: <code>HEAD</code> represents the current snapshot you are working on, usually pointing to the tip of the current branch.</p>
</li>
<li><p><strong>Unique Identifier:</strong> Each commit is identified by a 40-character SHA-1 hash. </p>
</li>
</ul>
<h3 id="heading-commit"><strong>📦 Commit</strong></h3>
<p>A <strong>commit</strong> is a snapshot <a target="_blank" href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwxn5vv8e520rs0oujee.png">of</a> your code at a specific point in time.</p>
<p>Think of a commit as: <strong>"Save point with a message"</strong></p>
<p>Each commit has:</p>
<ul>
<li><p>A unique ID (hash)</p>
</li>
<li><p>Author</p>
</li>
<li><p>Date</p>
</li>
<li><p>Message explaining the change</p>
</li>
</ul>
<h3 id="heading-branch"><strong>🌿 Branch</strong></h3>
<p>A <strong>branch</strong> lets you work on features independently.</p>
<ul>
<li><p><code>main</code> (or <code>master</code>) → default branch</p>
</li>
<li><p>Feature branches → new ideas or fixes</p>
</li>
</ul>
<p>Branches help you experiment without breaking main code.</p>
<h3 id="heading-head"><strong>📍 HEAD</strong></h3>
<p><strong>HEAD</strong> points to your current position in Git history.</p>
<p>Simply put: <strong>HEAD = "Where you are right now"</strong></p>
<p>Usually, HEAD points to the latest commit of the current branch.</p>
<h2 id="heading-git-repository-structure"><strong>Git Repository Structure</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767530080014/f98bb0d1-c125-4b71-96de-6e389470bc8d.png" alt class="image--center mx-auto" /></p>
<p>Your local repository consists of:</p>
<ul>
<li><p><strong>Working Directory</strong>: Your actual project files</p>
</li>
<li><p><strong>.git folder</strong>: All Git metadata and history</p>
</li>
<li><p><strong>Remote Repository</strong>: GitHub/GitLab (optional)</p>
</li>
</ul>
<h2 id="heading-common-git-commands-with-exahttpsmedia2devtodynamicimagewidth8002cheight2cfitscale-down2cgravityauto2cformatautohttps3a2f2fdev-to-uploadss3amazonawscom2fuploads2farticles2f925fjikl9gtvwjnyiyrlpngmples"><strong>Common Git Commands (With E</strong><a target="_blank" href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F925fjikl9gtvwjnyiyrl.png"><strong>xa</strong></a><strong>mples)</strong></h2>
<p>Let's learn Git commands by actually using them.</p>
<h3 id="heading-git-init"><strong>git init</strong></h3>
<p>Initializes Git in your project folder.</p>
<pre><code class="lang-javascript">git init
</code></pre>
<p>Creates a hidden <code>.git</code> folder that Git uses to track everything.</p>
<hr />
<h3 id="heading-git-status"><strong>git status</strong></h3>
<p>Shows the current state of your repository.</p>
<pre><code class="lang-javascript">git status
</code></pre>
<p>It tells you:</p>
<ul>
<li><p>Which files are new</p>
</li>
<li><p>Which files are modified</p>
</li>
<li><p>What is staged for commit</p>
</li>
</ul>
<p>👉 <strong>This is the most used Git command.</strong></p>
<hr />
<h3 id="heading-git-add"><strong>git add</strong></h3>
<p>Adds files to the staging area.</p>
<pre><code class="lang-javascript">git add filename.txt
</code></pre>
<p>Add everything:</p>
<pre><code class="lang-javascript">git add .
</code></pre>
<p>Staging means <strong>"I want to include this in the next commit</strong>.</p>
<hr />
<h3 id="heading-git-commit"><strong>git commit</strong></h3>
<p>Creates a snapshot of staged changes.</p>
<pre><code class="lang-javascript">git commit -m <span class="hljs-string">"Add initial project files"</span>
</code></pre>
<p>✔️ <strong>Always write clear and meaningful messages.</strong></p>
<hr />
<h3 id="heading-git-log"><strong>git log</strong></h3>
<p>Shows commit history.</p>
<pre><code class="lang-javascript">git log
</code></pre>
]]></content:encoded></item><item><title><![CDATA[JavaScript Closures Took Me a While to Understand And That Is Okay]]></title><description><![CDATA[A reflection on closures, memory, and behaviour
For a long time, I told myself I understood JavaScript closures.
I could repeat the definition. I knew they were related to scope. I had even used them in projects without thinking too much about it. Bu...]]></description><link>https://birendra.site/javascript-closures-took-me-a-while-to-understand-and-that-is-okay</link><guid isPermaLink="true">https://birendra.site/javascript-closures-took-me-a-while-to-understand-and-that-is-okay</guid><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Birendra K]]></dc:creator><pubDate>Sun, 04 Jan 2026 10:29:21 GMT</pubDate><content:encoded><![CDATA[<p><strong>A reflection on closures, memory, and behaviour</strong></p>
<p>For a long time, I told myself I understood JavaScript closures.</p>
<p>I could repeat the definition. I knew they were related to scope. I had even used them in projects without thinking too much about it. But if I am being honest, none of that meant they truly clicked.<br />And that is okay.</p>
<p>Closures are one of those ideas in JavaScript that do not reward memorisation. They reward time, exposure, and the uncomfortable moments where code behaves consistently while completely violating your expectations.</p>
<p>For me, that moment came in the form of a bug.</p>
<p><strong>The bug that forced me to actually understand closures</strong></p>
<p>The moment closures finally made sense did not come from documentation. It came from chasing behaviour that felt wrong, even though it was technically correct.</p>
<p>I was looping over a list and attaching handlers. Nothing clever. Nothing experimental. Just everyday JavaScript.</p>
<p>But every handler behaved as if it had forgotten which item it belonged to.</p>
<p>I assumed I had made a mistake. Then I assumed some shared state was being overwritten. I added logs. I rewrote the function. The behaviour did not change.</p>
<p>Every handler was seeing the same value.</p>
<p>A simplified version of the problem looked like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">3</span>; i++) {
  <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(i);
  }, <span class="hljs-number">1000</span>);
}
</code></pre>
<p>I expected to see 0, 1, and 2.</p>
<p>What I saw was 3, printed three times.</p>
<p>That was the moment I realised I was not dealing with a logic error. I was dealing with a misunderstanding of how JavaScript remembers things.</p>
<p>Each callback was not getting its own copy of the value. They were all holding onto the same variable. By the time the function actually ran, that variable had already changed.</p>
<p>Once I saw that, the behaviour stopped being mysterious. It was predictable. It was even reasonable.</p>
<p>The bug disappeared the moment I stopped asking why JavaScript was doing this and started asking what the function was still connected to.</p>
<p>That was the point where closures stopped being a definition and became a mental model.</p>
<p><strong>Closures are about environments, not syntax</strong></p>
<p>Closures are often introduced as a feature of functions. That framing is convenient, but it is incomplete.</p>
<p>Closures are not something you turn on by writing functions a certain way. They emerge from how JavaScript manages environments over time.</p>
<p>When a function is created, it is associated with the environment in which it was defined. That environment contains bindings, not frozen values. When the function later executes, it resolves those bindings by walking outward through its lexical environments.</p>
<p>A closure exists when that environment remains accessible beyond the lifetime of the original function call.</p>
<p><strong>Why closures persist after functions return</strong></p>
<p>A common misconception is that closures store values. They do not.</p>
<p>What persists is reachability.</p>
<p>If a function still has access to a variable, that variable remains reachable. If it remains reachable, it stays alive in memory. Garbage collection does not care where a variable was declared. It only cares whether something can still reach it.</p>
<p>Once you see closures as a consequence of reachability rather than a special feature, many confusing behaviours stop feeling arbitrary.</p>
<p><strong>Closures explain bugs before they explain features</strong></p>
<p>Most developers encounter closures through bugs long before they use them deliberately.</p>
<p>Asynchronous callbacks, event handlers, and timers all expose the same underlying behaviour. Closures capture variables, not moments in time. Multiple functions can close over the same binding. Delayed execution simply makes this visible.</p>
<p>Understanding this shifts closures from being an interview topic to being a practical debugging tool.</p>
<p><strong>Closures are foundational to encapsulation</strong></p>
<p>Before modern class syntax and private fields, closures were the primary way JavaScript achieved encapsulation.</p>
<p>Even now, they offer something classes cannot always provide cleanly. Privacy without exposure.</p>
<p>A variable that exists only inside a function scope and is accessed only through returned functions is fundamentally inaccessible from the outside. No keyword is required. The structure enforces it naturally.</p>
<p>Closures support intentional design by keeping state local and controlled.</p>
<p><strong>Closures and functional composition</strong></p>
<p>Closures become especially powerful when combined with higher order functions.</p>
<p>Functions that return functions, partially apply arguments, or generate specialised behaviour all rely on closures. This is not an advanced trick. It is a natural extension of how environments work.</p>
<p>Once closures stop feeling mysterious, patterns like currying and composition start to feel obvious rather than clever.</p>
<p><strong>The real cost of closures</strong></p>
<p>Closures are often blamed for performance problems, but that concern is usually misplaced.</p>
<p>The real cost of closures is responsibility.</p>
<p>If you close over large objects, DOM nodes, or long lived references unintentionally, you extend their lifetime. That can lead to memory retention that is difficult to spot.</p>
<p>This is not a reason to avoid closures. It is a reason to understand them well enough to use them deliberately.</p>
<p><strong>A more accurate mental model</strong></p>
<p>After spending time with closures in real code, the most accurate mental model I have found is this:</p>
<p>A closure is not something you create.<br />A closure is something that remains.</p>
<p>It is the result of:</p>
<ul>
<li><p>lexical scoping</p>
</li>
<li><p>name resolution</p>
</li>
<li><p>reference reachability</p>
</li>
<li><p>delayed or repeated execution</p>
</li>
</ul>
<p>When these conditions align, a closure exists.</p>
<p><strong>Why it is okay that closures take time</strong></p>
<p>Closures sit below the surface of JavaScript. You can write code for years without naming them explicitly. That does not mean you are not using them. It means the language is doing its job.</p>
<p>Understanding closures deeply requires encountering unexpected behaviour, tracing execution mentally, and thinking about memory rather than just output.</p>
<p>That is not beginner work.</p>
<p>If closures took you a while to understand, that is not a failure. It is part of becoming fluent.</p>
<p>They took me a while too.</p>
<p>And that is okay.</p>
<p><strong>Further reading</strong></p>
<p>The ideas in this article were shaped over time by reading and experience. These resources were especially helpful:</p>
<ul>
<li><p>JavaScript from Beginner to Professional. For practical reinforcement of function scope and nested behaviour.</p>
</li>
<li><p>Eloquent JavaScript (4th Edition) by Marijn Haverbeke. For building intuition around nested scope and environments.</p>
</li>
<li><p>Clean Code in JavaScript by James Padolsey. For connecting closures to encapsulation, maintainability, and intentional design.</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>