<?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[WebDev Cohort - 2026]]></title><description><![CDATA[WebDev Cohort - 2026]]></description><link>https://devasif-7.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 14:00:14 GMT</lastBuildDate><atom:link href="https://devasif-7.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[JavaScript Objects Explained: Properties, Methods & More]]></title><description><![CDATA[What Is an Object in JavaScript, and How Can You Access Properties from an Object?
In JavaScript, an object is a fundamental data structure that allows you to store and organize related data and funct]]></description><link>https://devasif-7.hashnode.dev/javascript-objects</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/javascript-objects</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Fri, 11 Sep 2026 12:42:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/b800c0f4-6286-4fc9-b616-5c95609831b6.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3><em><strong>What Is an</strong></em> <code>Object</code> <em><strong>in JavaScript, and How Can You Access</strong></em> <code>Properties</code> <em><strong>from an</strong></em> <code>Object</code><em><strong>?</strong></em></h3>
<p>In JavaScript, an <code>object</code> is a fundamental <em><strong>data structure</strong></em> that allows you to store and organize <code>related</code> <em><strong>data</strong></em> and <em><strong>functionality</strong></em>.</p>
<p>You can think of an <code>object</code> as a <code>container</code> that holds various pieces of <em><strong>information</strong></em>, much like a <em><strong>filing cabinet</strong></em> holds different <em><strong>folders</strong></em> and <em><strong>documents</strong></em>.</p>
<p>These pieces of information are called <code>properties</code>, and they consist of a <code>name (or key)</code> and a <code>value</code>.</p>
<pre><code class="language-javascript">const exampleObject = {
  propertyName: value,
}
</code></pre>
<p><code>Objects</code> are incredibly versatile and form the <code>backbone</code> of JavaScript. In fact, almost <code>everything</code> in JavaScript is an <code>object</code> or can be <code>treated</code> as one.</p>
<p>This includes <code>arrays</code>, <code>functions</code>, and even <code>primitive</code> <em><strong>data types</strong></em> like <code>strings</code> and <code>numbers</code> when used in certain ways.</p>
<p>This <code>object-centric</code> nature of <em><strong>JavaScript</strong></em> is one of the reasons it's such a flexible and powerful language. Let's look at how you can create an <code>object</code>:</p>
<pre><code class="language-javascript">const person = {
  name: "Alice",
  age: 30,
  city: "New York"
};
</code></pre>
<p>In this example, we've created an <code>object</code> called <code>person</code> with three properties: <code>name</code>, <code>age</code>, and <code>city</code>. Each property has a <code>name</code> and a <code>value</code>, separated by a <code>colon</code>. This is <code>object literal</code>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/f6ac12d5-87f9-467e-81c8-dbaecb76158f.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>How to access properties of object</strong></em></h3>
<p>Now, let's explore how you can <code>access</code> these properties. There are <code>two</code> main ways to access <code>object</code> properties in JavaScript: <code>dot notation</code> and <code>bracket notation</code>.</p>
<h3><em><strong>Dot notation</strong></em></h3>
<p><code>Dot notation</code> is the most common and straightforward way to access object properties. Here is the basic syntax for <code>dot notation</code>:</p>
<pre><code class="language-javascript">objectName.propertyName
</code></pre>
<p>Here's how you would use dot notation with our <code>person</code> object:</p>
<pre><code class="language-javascript">const person = {
  name: "Alice",
  age: 30,
  city: "New York"
};

console.log(person.name);  // Alice
console.log(person.age);   // 30
</code></pre>
<p><code>Dot notation</code> is concise and easy to read, making it the preferred choice when you know the <code>exact</code> name of the <code>property</code> you want to access and that <code>name</code> is a valid JavaScript <code>identifier</code> (meaning it doesn't start with a number and doesn't contain special characters or spaces).</p>
<h3><em><strong>Bracket notation</strong></em></h3>
<p><code>Bracket notation</code>, on the other hand, allows you to access object properties using a <code>string</code> inside square brackets. Here's how you would use bracket notation:</p>
<pre><code class="language-javascript">const person = {
  name: "Alice",
  age: 30,
  city: "New York"
};

console.log(person["name"]); // Alice
console.log(person["age"]); //  30
</code></pre>
<p><code>Bracket notation</code> is more flexible than <code>dot notation</code> because it allows you to use <code>property</code> names that aren't valid JavaScript <code>identifiers</code>. For example, if you had a property name with <code>spaces</code> or that starts with a <code>number</code>, you'd need to use <code>bracket</code> <code>notation</code>:</p>
<pre><code class="language-javascript">const oddObject = {
  "1stProperty": "Hello",
  "property with spaces": "World"
};

console.log(oddObject["1stProperty"]);  // Hello
console.log(oddObject["property with spaces"]);  // World
</code></pre>
<p>Another advantage of <code>bracket notation</code> is that it allows you to use <code>variables</code> to access properties <code>dynamically</code>:</p>
<pre><code class="language-javascript">const person = {
  name: "Alice",
  age: 30,
  city: "Wonderland"
};

let propertyName = "city";
console.log(person[propertyName]); // Wonderland
</code></pre>
<p>This flexibility makes <code>bracket notation</code> particularly useful when you don't know the <code>exact</code> property name at the time you're writing the code, or when you're working with property names that come from <code>user</code> input or some other <code>dynamic</code> source.</p>
<p>It's worth noting that <code>objects</code> in JavaScript are incredibly powerful and versatile. They can contain not just <code>simple</code> values like <code>strings</code> and <code>numbers</code>, but also <code>arrays</code>, or other <code>objects</code>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/6a91654a-215a-41a5-bd50-2005e540144d.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>How Can You</strong></em> <code>Remove</code> <em><strong>Properties from an</strong></em> <code>Object</code><em><strong>?</strong></em></h3>
<p>There are several ways to <code>remove</code> properties from an <code>object</code>, with the <code>delete</code> operator being the most straightforward and commonly used method.</p>
<p>When you use <code>delete</code>, it <code>removes</code> the <code>selected</code> property from the <code>object</code>. Here's an example of how to use the <code>delete</code> operator:</p>
<pre><code class="language-javascript">const person = {
  name: "Alice",
  age: 30,
  job: "Engineer"
};

delete person.job;

console.log(person.job); // undefined
</code></pre>
<p>In this example, we start with a <code>person</code> object that has three properties: <code>name</code>, <code>age</code>, and <code>job</code>. Then, we use the <code>delete</code> operator to <code>remove</code> the <code>job</code> property. After the <code>deletion</code>, the <code>person</code> object no longer has the <code>job</code> property.</p>
<p>Another way to remove properties is by using <code>destructuring</code> assignment with <code>rest</code> parameters. This approach doesn't actually <code>delete</code> the property, but it creates a <code>new</code> object without the specified properties:</p>
<pre><code class="language-javascript">const person = {
  name: "Bob",
  age: 25,
  job: "Designer",
  city: "New York"
};

const { job, city, ...remainingProperties } = person;

// { name: "Bob", age: 25 }
console.log(remainingProperties);
</code></pre>
<p>In this example, we use <code>destructuring</code> to extract <code>job</code> and <code>city</code> from the <code>person</code> object, and collect the remaining properties into a <code>new</code> object called <code>remainingProperties</code>. This creates a <code>new</code> object without the <code>job</code> and <code>city</code> properties.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/8530c7eb-8eb5-47db-af90-590203427384.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>How to Check If an</strong></em> <code>Object Has a Property</code><em><strong>?</strong></em></h3>
<h3><em><strong>hasOwnProperty() method</strong></em></h3>
<p>In JavaScript, there are several ways to check if an <code>object</code> has a specific <code>property</code>. Understanding these methods is important for working effectively with <code>objects</code>, especially when you're dealing with data from <code>external</code> sources or when you need to ensure <code>certain</code> properties <code>exist</code> before using them.</p>
<p>We'll explore some common approaches: the <code>hasOwnProperty()</code> method, the <code>Object.hasOwn()</code> method, the <code>in</code> operator, and checking against <code>undefined</code>.</p>
<p>Let's start with the <code>hasOwnProperty()</code> method. This method returns a <code>boolean</code> indicating whether the object has the specified property as its <code>own</code> property. Here's an example:</p>
<pre><code class="language-javascript">const person = {
  name: "Alice",
  age: 30
};

console.log(person.hasOwnProperty("name")); // true
console.log(person.hasOwnProperty("job")); // false
</code></pre>
<p>In this example, we have an object called <code>person</code> with two properties: <code>name</code> and <code>age</code>. To check if <code>name</code> is a property in the <code>person</code> object, we use the <code>hasOwnProperty()</code> method. Since <code>name</code> is a property, it will return <code>true</code>. But when we use the <code>hasOwnProperty()</code> to check if <code>job</code> is a property, it will return <code>false</code> because it does not exist in the object.</p>
<h3><em><strong>Object.hasOwn() method</strong></em></h3>
<p><code>Object.hasOwn()</code> is the modern, recommended way to check if an object has a property as its own (not inherited). Think of it as an upgraded, safer version of <code>hasOwnProperty()</code>. The syntax is <code>Object.hasOwn(object, propertyName)</code> — you pass the <code>object</code> as the <code>first</code> argument and the property name as the <code>second</code>.</p>
<p>Here is a basic example:</p>
<pre><code class="language-javascript">const person = {
  name: "Alice",
  age: 30
};

console.log(Object.hasOwn(person, "name")); // true
console.log(Object.hasOwn(person, "job")); // false
</code></pre>
<p>In this example, <code>Object.hasOwn(person, "name")</code> returns <code>true</code> because <code>name</code> exists directly on the <code>person</code> object. <code>Object.hasOwn(person, "job")</code> returns <code>false</code> because <code>job</code> was never added to the object.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/acb9166c-0231-4ea0-8800-261a5e2e6bee.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>Alert:</strong></em></h3>
<p>A very important thing to understand is that <code>Object.hasOwn()</code> only checks if the property <strong>exists</strong> - it does not care about the <code>property's value</code>. This means it still returns <code>true</code> even when the value is <code>0</code>, <code>false</code>, <code>null</code>, or <code>undefined</code>:</p>
<pre><code class="language-javascript">const user = {
  username: "coder123",
  score: 0,
  isActive: false,
  nickname: null
};

// Object.hasOwn() correctly reports these all exist
console.log(Object.hasOwn(user, "score"));    // true  (value is 0, but property exists)
console.log(Object.hasOwn(user, "isActive")); // true  (value is false, but property exists)
console.log(Object.hasOwn(user, "nickname")); // true  (value is null, but property exists)
console.log(Object.hasOwn(user, "email"));   // false (property was never added)

// Danger! Using if() directly gives wrong results for falsy values
if (user.score) {
  console.log("Has score"); // This will NOT print even though score exists!
}

// Safe! Object.hasOwn() gives correct result
if (Object.hasOwn(user, "score")) {
  console.log("Has score:", user.score); // Has score: 0
}
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/0ed435a3-8669-4dbc-bf36-b4cc48002ef5.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>in operator</strong></em></h3>
<p>Another way to check for the <code>existence</code> of a property in an <code>object</code> is to use the <code>in</code> operator. Like <code>hasOwnProperty()</code>, the <code>in</code> operator will return <code>true</code> if the property <code>exists</code> on the object. Here's how you can use it:</p>
<pre><code class="language-javascript">const person = {
  name: "Bob",
  age: 25
};
console.log("name" in person);  // true
</code></pre>
<p>In this example, <code>"name" in person</code> returns <code>true</code> because <code>name</code> is a property of <code>person</code>.</p>
<p>The third method involves checking if a property is <code>undefined</code>. This approach can be useful, but it has some limitations. Here's an example:</p>
<pre><code class="language-javascript">const car = {
  brand: "Toyota",
  model: "Corolla",
  year: 2020
};

console.log(car.brand !== undefined); // true
console.log(car.color !== undefined); // false
</code></pre>
<p>In this code, we check if <code>car.brand</code> and <code>car.color</code> are not <code>undefined</code>. This works because accessing a non-existent property on an object returns <code>undefined</code>. However, this method can give false negatives if a property explicitly has the value <code>undefined</code>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/166c2cc1-3195-4f9d-990b-ff6a185727c6.jpg" alt="" style="display:block;margin:0 auto" />

<div>
<div>💡</div>
<div><strong>Once you understand how JavaScript objects work, you’re not just storing data, you’re learning how JavaScript structures and manages it.</strong></div>
</div>]]></content:encoded></item><item><title><![CDATA[JavaScript Strings Explained: From length to includes()]]></title><description><![CDATA[What the string is in JavaScript?
A JavaScript string is a sequence of characters, typically used to represent text.
We can either use a single quote ('') or a double quote ("") or a back-ticks (``) t]]></description><link>https://devasif-7.hashnode.dev/javascript-strings</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/javascript-strings</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[webdevelopment]]></category><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Thu, 10 Sep 2026 15:34:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/0c97f504-a6cf-4b0d-a925-fa832236b1d8.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3><em><strong>What the string is in JavaScript?</strong></em></h3>
<p>A JavaScript <em><strong>string</strong></em> is a sequence of characters, typically used to represent <em><strong>text</strong></em>.</p>
<p>We can either use a <em><strong>single quote</strong></em> <code>('')</code> or a <em><strong>double quote</strong></em> <code>("")</code> or a <em><strong>back-ticks</strong></em> <code>(``)</code> to create a <em><strong>string</strong></em>. We can use either of the <em><strong>three</strong></em>, but it is recommended to be consistent with your choice throughout your code.</p>
<pre><code class="language-javascript">// Using Single Quote
let firstName = 'Ayan';
console.log(firstName);

// Using Double Quote
let middleName = "Shahid";
console.log(middleName);

//Using Backticks
let lastName = `Khan`;
console.log(lastName);
</code></pre>
<div>
<div>💡</div>
<div>You can create a <strong><em>multiline</em></strong> <strong><em>string</em></strong> using <strong><em>backticks</em></strong> <code>(``)</code>.</div>
</div>

<blockquote>
<p>Strings are immutable.</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/cd2ea58c-51e6-4564-814c-964aa50324b5.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em>Finding the length of a String</em></h3>
<p>You can find the <code>length</code> of a string using the <code>length</code> property.</p>
<pre><code class="language-javascript">let s = 'JavaScript';
let len = s.length;

console.log("String Length: " + len);
</code></pre>
<h3><strong>What Is Bracket Notation, and How Do You Access Characters from a String?</strong></h3>
<p>In JavaScript, <code>strings</code> are treated as <code>sequences of characters</code>, and each <code>character</code> in a <code>string</code> can be accessed using <code>bracket notation</code>. This allows you to retrieve a <code>specific</code> character from a <code>string</code> based on its position, which is called its <code>index</code>.</p>
<p>An <code>index</code> is the <code>position</code> of a character within a <code>string</code>, and it is <code>zero-based</code>. This means that the <code>first</code> character of a string has an index of <code>0</code>, the <code>second</code> character has an index of <code>1</code>, and so on.</p>
<p>For example, in the string <code>hello</code>, the character <code>h</code> is at index <code>0</code>, <code>e</code> is at index <code>1</code>, <code>l</code> is at index <code>2</code>, and so on.</p>
<p><code>Bracket notation</code> uses square brackets (<code>[]</code>) and the <code>index</code> of the character you want to access. Let’s look at an example:</p>
<pre><code class="language-javascript">let greeting = "hello";
console.log(greeting[1]); // "e"
</code></pre>
<p>In this example, we can access the character at index <code>1</code>, which is <code>e</code>.</p>
<p>To get the <code>last</code> character of a <code>string</code>, you can use the <code>length</code> of the string <code>minus one</code>. The <code>length</code> property of a <code>string</code> tells you how many characters it contains, so to access the <code>last</code> character, you would subtract <code>one</code> from the length:</p>
<pre><code class="language-javascript">let greeting = "hello";
console.log(greeting[greeting.length - 1]); // "o"
</code></pre>
<p>In this case, the <code>length</code> of <code>hello</code> is <code>5</code>, and the last character (<code>o</code>) is at index <code>4</code> which is <code>5 - 1</code>.</p>
<p>If you want to get <code>multiple</code> characters, you can use <code>bracket</code> notation like this:</p>
<pre><code class="language-javascript">let greeting = "hello";
let firstTwo = greeting[0] + greeting[1]; // "he"
console.log(firstTwo);
</code></pre>
<p>In this example, we are <code>concatenating</code> the <code>first</code> and <code>second</code> characters using <code>bracket</code> notation to form the string <code>he</code>.</p>
<p><code>Bracket notation</code> is useful when you need to access <code>specific</code> characters in a string, such as extracting <code>initials</code> from a name or checking a specific letter for validation.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/50d0afe1-31fb-4d32-b703-b3f1e4627abd.jpg" alt="" style="display:block;margin:0 auto" />

<h3><strong>How Can You Find the</strong> <code>Position</code> <strong>of a</strong> <code>Substring</code> <strong>in a</strong> <code>String</code> <code>indexOf</code> method?</h3>
<p>When working with strings in JavaScript, there may be times when you need to locate the position of a specific <code>substring</code> within a larger string.</p>
<p>A <code>substring</code> is a sequence of characters that appears <code>within</code> a larger string. For example, in the string <code>hello world</code>, <code>hello</code> and <code>world</code> are <code>substrings</code>.</p>
<p>To locate the position of a <code>substring</code> inside of a <code>string</code>, you can use the <code>indexOf()</code> method.</p>
<p>The <code>indexOf()</code> method in JavaScript allows you to search for a <code>substring</code> within a <code>string</code>.</p>
<p>If the substring is found, <code>indexOf()</code> returns the <code>index (or position)</code>of the <code>first occurrence</code> of that <code>substring</code>. If the <code>substring</code> is not found, <code>indexOf()</code> returns <code>-1</code>, which indicates that the search was unsuccessful.</p>
<p>The <code>indexOf()</code> method takes <code>two</code> arguments: the first is the <code>substring</code> you want to find within the larger <code>string</code>, and the second is an <code>option starting position</code> for the search. If you don’t provide a <code>starting</code> position, the search will begin at the <code>start</code> of the string.</p>
<p>In this context, an <code>argument</code> is a value you give to a <code>function</code> or method when you <code>call</code> it, enabling that <code>function</code> or <code>method</code> to perform its task using the specific <code>information</code> you provide. You will learn more about <code>arguments</code> in future lessons.</p>
<p>Here is an example of using the <code>indexOf()</code> method to find the position for the string <code>awesome</code>:</p>
<pre><code class="language-javascript">let sentence = "JavaScript is awesome!";
let position = sentence.indexOf("awesome!");
console.log(position); // 14
</code></pre>
<p>In this example, the word <code>awesome</code> starts at index <code>14</code> in the string <code>JavaScript is awesome!</code>, so the <code>indexOf()</code> method returns <code>14</code>.</p>
<p>Now, let's see what happens when the <code>substring</code> isn't found:</p>
<pre><code class="language-javascript">let sentence = "JavaScript is awesome!";
let position = sentence.indexOf("fantastic");
console.log(position); // -1
</code></pre>
<p>Since the word <code>fantastic</code> does not appear in the <code>string</code>, the method returns <code>-1</code>.</p>
<p>You can also specify where to <code>begin</code> searching within the <code>string</code> by providing a <code>second</code> argument to <code>indexOf()</code>. Here's an example:</p>
<pre><code class="language-javascript">let sentence = "JavaScript is awesome, and JavaScript is powerful!";
let position = sentence.indexOf("JavaScript", 10);
console.log(position); // 27
</code></pre>
<p>In this case, the search for <code>JavaScript</code> begins after the <code>10th</code> character, and so the <code>second</code> occurrence of <code>JavaScript</code> is found at index <code>27</code>.</p>
<p>It is important to note that the <code>indexOf()</code> method is <code>case sensitive</code>.</p>
<pre><code class="language-javascript">console.log("freeCodeCamp".indexOf("F")) // -1
</code></pre>
<p>Using <code>indexOf()</code> can be very useful when you need to check if a <code>substring</code> is present in a <code>string</code> and to determine its <code>position</code> for further operations.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/8b9b16e4-0599-4cb8-a489-736a4eb82981.jpg" alt="" style="display:block;margin:0 auto" />

<h3><strong>How</strong> <code>ASCII</code> <strong>Does It Work with</strong> <code>charCodeAt()</code> <strong>and</strong> <code>fromCharCode()</code><strong>?</strong></h3>
<p>In this lesson, we will explore what <code>ASCII</code> is, how it works, and how JavaScript methods like <code>charCodeAt()</code> and <code>fromCharCode()</code> relate to character encoding. While JavaScript strings use <code>Unicode (UTF-16)</code> internally, <code>ASCII</code> values match the first <code>128</code> Unicode characters, which is why <code>ASCII</code>-based examples work in JavaScript.</p>
<p>ASCII is a system for encoding characters such as <code>letters</code>, <code>digits</code>, and <code>symbols</code> into numerical values. Each character is mapped to a specific number.</p>
<p>For example, the capital letter <code>A</code> is represented by the number <code>65</code> in ASCII, while the lowercase <code>a</code> is represented by <code>97</code>. This encoding allows computers to store and manipulate text.</p>
<p>The ASCII standard covers <code>128</code> characters including:</p>
<ul>
<li><p><code>Uppercase</code> and <code>lowercase</code> English letters (<code>A-Z, a-z</code>).</p>
</li>
<li><p><code>Numbers</code> <code>(0-9)</code>.</p>
</li>
<li><p>Common punctuation marks and symbols <code>(!, @, #, and so on)</code>.</p>
</li>
<li><p>Control characters (such as <code>newline</code> and <code>tab</code>).</p>
</li>
</ul>
<p>In JavaScript, you can access the <code>numeric code</code> of a <code>character</code> using the <code>charCodeAt()</code> method. This method returns the <code>UTF-16</code> code unit of the character at a <code>specified</code> index. For the first <code>128</code> characters, this value matches the <code>ASCII</code> code.</p>
<p>Let’s take a look at an example:</p>
<pre><code class="language-javascript">let letter = "A";
console.log(letter.charCodeAt(0));  // 65
</code></pre>
<p>In this example, <code>A</code> is the first character of the string, and calling <code>charCodeAt(0)</code> returns its numeric code (which matches its <code>ASCII</code> value for basic <code>Latin</code> characters), <code>65</code>.</p>
<p>You can also use this method with other characters to find their numeric code values:</p>
<pre><code class="language-javascript">let symbol = "!";
console.log(symbol.charCodeAt(0));  // 33
</code></pre>
<p>Here, the numeric code for the exclamation mark <code>!</code> is returned as <code>33</code> (which matches its <code>ASCII</code> value).</p>
<p>While <code>charCodeAt()</code> helps you retrieve the numeric code of a character, the <code>fromCharCode()</code> method allows you to do the opposite: convert a UTF-16 code unit (which matches ASCII for basic characters) into its corresponding character.</p>
<p>Let's see this in action:</p>
<pre><code class="language-javascript">let char = String.fromCharCode(65);
console.log(char);  //  A
</code></pre>
<p>In this example, <code>fromCharCode(65)</code> converts the numeric code <code>65</code> (which matches the ASCII value for <code>A</code>) back to the character <code>A</code>.</p>
<p>Another example would be converting the number <code>97</code> to its corresponding lowercase letter:</p>
<pre><code class="language-javascript">let char = String.fromCharCode(97);
console.log(char);  // a
</code></pre>
<p>These methods are particularly useful when you need to manipulate or compare characters based on their numeric code values.</p>
<p>For instance, you might use <code>charCodeAt()</code> to check if a character is uppercase, lowercase, or a digit by comparing its ASCII value.</p>
<p>On the other hand, <code>fromCharCode()</code> can be used to dynamically generate characters from their ASCII codes.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/27021b87-5b8c-45e2-8142-3a06526bc2f0.jpg" alt="" style="display:block;margin:0 auto" />

<h3><strong>How Can You Test if a</strong> <code>String</code> <strong>Contains a</strong> <code>Substring</code> <code>includes()</code> method?</h3>
<p>When working with <code>strings</code> in JavaScript, there are many cases where you might need to check whether a string contains a specific <code>substring</code>, which is a smaller part of that <code>string</code>.</p>
<p>For example, you might want to check if a user's input includes a specific word or character before performing some action. One way to achieve this is by using the <code>includes()</code> method.</p>
<p>The <code>includes()</code> method is used to check if a <code>string</code> contains a specific <code>substring</code>. If the <code>substring</code> is found within the <code>string</code>, the method returns <code>true</code> otherwise, it returns <code>false</code>.</p>
<p>Here's the basic syntax:</p>
<pre><code class="language-javascript">string.includes(searchValue);
</code></pre>
<p>For the syntax, the <code>searchValue</code> is the substring you want to look for within the string. And here's an example:</p>
<pre><code class="language-javascript">let phrase = "JavaScript is awesome!";
let result = phrase.includes("awesome");

console.log(result);  // true
</code></pre>
<p>In this example, the word <code>awesome</code> is found within the string <code>JavaScript is awesome!</code>, so the <code>includes()</code> method returns <code>true</code>.</p>
<p>It's important to note that the <code>includes()</code> method is <code>case-sensitive</code>. This means that the exact match of the characters is required, including their case.</p>
<pre><code class="language-javascript">let phrase = "JavaScript is awesome!";
let result = phrase.includes("Awesome");

console.log(result);  // false
</code></pre>
<p>Since <code>Awesome</code> (with an uppercase <code>A</code>) does not match <code>awesome</code> (with a lowercase <code>a</code>), the result is <code>false</code>.</p>
<p>You can also use the <code>includes()</code> method to check for a substring starting at a specific index in the string by providing a second parameter:</p>
<pre><code class="language-javascript">let text = "Hello, JavaScript world!";
let result = text.includes("JavaScript", 7);

console.log(result);  // true
</code></pre>
<p>Here, the search for the substring <code>JavaScript</code> starts from the 7th position in the string, ensuring it skips any characters before this position.</p>
<p>The <code>includes()</code> method only returns a <code>true</code> or <code>false</code> result. It does not provide information on where the substring is located in the string or how many times it occurs. If you need that level of detail, other methods, such as the <code>indexOf()</code> method might be more suitable.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/3c25eb99-d370-4d5b-a789-946c22e5fa71.jpg" alt="" style="display:block;margin:0 auto" />

<h3><strong>How Can You Extract a</strong> <code>Substring</code> <strong>from a</strong> <code>String</code> <code>slice()</code> method?</h3>
<p>When working with <code>strings</code> in JavaScript, you often need to extract a portion or <code>substring</code> from a larger string.</p>
<p>For example, you may want to <code>extract</code> part of a word, a specific character sequence, or just a fragment of a sentence.</p>
<p>JavaScript provides several methods for this task, one of the most commonly used being the <code>slice()</code> method.</p>
<p>The <code>slice()</code> method allows you to extract a portion of a <code>string</code> and returns a <code>new string</code>, without modifying the <code>original string</code>. It takes <code>two</code> parameters: the <code>starting index</code> and the optional <code>ending index</code>.</p>
<p>Here's the basic syntax:</p>
<pre><code class="language-javascript">string.slice(startIndex, endIndex);
</code></pre>
<p><code>startIndex</code> <code>(inclusive)</code>is the position where the extraction starts. <code>endIndex</code> <code>(exclusive)</code> is where the extraction ends. If not provided, <code>slice()</code> extracts until the <code>end</code> of the string.</p>
<p>Let's look at a simple example of extracting part of a string:</p>
<pre><code class="language-javascript">let message = "Hello, world!";
let greeting = message.slice(0, 5);

console.log(greeting);  // Hello
</code></pre>
<p>In this example, <code>slice(0, 5)</code> extracts characters starting from index <code>0</code> up to but not including index <code>5</code>. As a result, the word <code>Hello</code> is extracted.</p>
<p>If you omit the <code>second</code> parameter, <code>slice()</code> will extract everything from the start index to the <code>end</code> of the string:</p>
<pre><code class="language-javascript">let message = "Hello, world!";
let world = message.slice(7);

console.log(world);  // world!
</code></pre>
<p>Here, <code>slice(7)</code> extracts the string from index <code>7</code> to the end of the string, resulting in <code>world!</code>.</p>
<p>You can also use <code>negative</code> numbers as <code>indexes</code>. When you use a negative number, it counts backward from the <code>end</code> of the string:</p>
<pre><code class="language-javascript">let message = "JavaScript is fun!";
let lastWord = message.slice(-4);

console.log(lastWord);  // fun!
</code></pre>
<p>In this case, <code>slice(-4)</code> extracts the last four characters from the string, giving us <code>fun!</code>.</p>
<p>Let's say you want to extract a section from the <code>middle</code> of a string. You can provide both the <code>starting</code> and <code>ending</code> indexes to precisely control which part of the string you want:</p>
<pre><code class="language-javascript">let message = "I love JavaScript!";
let language = message.slice(7, 17);

console.log(language);  // JavaScript
</code></pre>
<p>Here, <code>slice(7, 17)</code> extracts the <code>substring</code> <code>starting</code> at index 7 and <code>ending</code> right before index <code>17</code>, which is the word <code>JavaScript</code>.</p>
<p>The <code>slice()</code> method is a powerful tool for extracting parts of a string in JavaScript.</p>
<p>You specify the <code>start</code> and <code>end</code> indexes, and the method returns a new string that contains the extracted portion.</p>
<p>With options for positive, negative, and omitted indexes, you can adapt it to various situations without altering the original string.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/0dbfa12f-507d-42bb-84b4-50e111570232.jpg" alt="" style="display:block;margin:0 auto" />

<h3>Working with <code>String</code> Formatting Methods</h3>
<p><code>toUpperCase()</code> and <code>toLowerCase()</code> Methods:</p>
<h3><code>toUpperCase()</code> Method</h3>
<p>The <code>toUpperCase()</code> method converts all the characters to uppercase letters and returns a new string with all uppercase characters. This is useful when you want to emphasize text or create consistency in the format of strings.</p>
<p>Let's see an example:</p>
<pre><code class="language-javascript">let greeting = "Hello, World!";
let uppercaseGreeting = greeting.toUpperCase();
console.log(uppercaseGreeting);  // "HELLO, WORLD!"
</code></pre>
<p>In this code, the <code>toUpperCase()</code> method transforms the entire string into uppercase letters.</p>
<h3><code>toLowerCase()</code> Method</h3>
<p>On the flip side, the <code>toLowerCase()</code> method converts all characters in a string to lowercase. This is helpful when you need to standardize input, such as when comparing user-provided text or making case-insensitive checks.</p>
<p>Let's look at an example:</p>
<pre><code class="language-javascript">let shout = "I AM LEARNING JAVASCRIPT!";
let lowercaseShout = shout.toLowerCase();
console.log(lowercaseShout);  // "i am learning javascript!
</code></pre>
<p>The <code>toLowerCase()</code> method converts all characters to lowercase, making the string less aggressive, while leaving the original string unchanged.</p>
<p>These methods are particularly useful for standardizing text input, making case-insensitive comparisons, and ensuring design consistency.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/c30497b3-622e-4290-b289-ca153bbe4b39.jpg" alt="" style="display:block;margin:0 auto" />

<h3><strong>How Can You</strong> <code>Trim</code> <code>Whitespace</code> (empty spaces) <strong>from a String?</strong></h3>
<p>When working with strings in JavaScript, it's common to encounter unwanted <code>whitespace</code> at the beginning or end of a string. <code>Whitespace</code> can interfere with operations like comparison, storage, or display, which is why it's important to know how to remove it efficiently.</p>
<p>In this lesson, we'll explore how you can trim <code>whitespace</code> using JavaScript's <code>trim()</code>, <code>trimStart()</code>, and <code>trimEnd()</code> methods.</p>
<p><code>Whitespace</code> refers to spaces, tabs, or line breaks that occur in a string but are not visible characters. For example:</p>
<pre><code class="language-javascript">let greeting = "   Hello, world!   ";
</code></pre>
<p>In this case, there are spaces before and after the visible text, <code>Hello, world!</code>.</p>
<p>The <code>trim()</code> method is the most commonly used way to remove whitespace from both the beginning and the end of a string. Here's an example:</p>
<pre><code class="language-javascript">let message = "   Hello!   ";
console.log(message); // "   Hello!   "
let trimmedMessage = message.trim();
console.log(trimmedMessage);  // "Hello!"
</code></pre>
<p>In this case, the <code>trim()</code> method removes all the leading and trailing spaces, leaving just <code>Hello!</code>. Note that any whitespace within the string (between words, for example) is left untouched by <code>trim()</code>.</p>
<p>Sometimes, you may only want to remove whitespace from either the beginning or the end of a string, but not both. This is where <code>trimStart()</code> and <code>trimEnd()</code> come in.</p>
<p><code>trimStart()</code> removes whitespace from the beginning (or start) of the string.</p>
<pre><code class="language-javascript">let greeting = "   Hello!   ";
console.log(greeting);  // "   Hello!   "
let trimmedStart = greeting.trimStart();
console.log(trimmedStart);  // "Hello!   "
</code></pre>
<p><code>trimEnd()</code> removes whitespace from the end of the string.</p>
<pre><code class="language-javascript">let greeting = "   Hello!   ";
console.log(greeting);  // "   Hello!   "
let trimmedEnd = greeting.trimEnd();
console.log(trimmedEnd);  // "   Hello!"
</code></pre>
<p>These methods give you more precise control over which part of the string you want to clean up.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/7de0f7e5-5734-4d6c-8859-816a2fe0d5b6.jpg" alt="" style="display:block;margin:0 auto" />

<h3><strong>How Can You</strong> <code>Replace</code> <strong>Parts of a String with Another</strong> <code>replace()</code> <strong>method?</strong></h3>
<p>In JavaScript, there are many scenarios where you may need to <code>replace</code> a portion of a string with <code>another</code> string.</p>
<p>For instance, you might need to update user information in a URL, change the formatting of dates, or correct errors in user-generated content.</p>
<p>The <code>replace()</code> method in JavaScript allows you to find a specified value (like a word or character) in a string and <code>replace</code> it with <code>another</code> value. The method returns a <code>new string</code> with the <code>replacement</code> and leaves the <code>original</code> unchanged because JavaScript strings are immutable.</p>
<p>Here is the basic syntax:</p>
<pre><code class="language-javascript">string.replace(searchValue, newValue);
</code></pre>
<p><code>searchValue</code> is the value you want to search for in the string. It can be either a <code>string</code> or a <code>regular expression (regex)</code>, which describes <code>patterns</code> in text. This allows you to search for and manipulate strings in a flexible and powerful way. You'll learn more about <code>regular</code> expressions in future lessons.</p>
<p>The <code>newValue</code> is the value that will replace the <code>searchValue</code>. Here's a simple example:</p>
<pre><code class="language-javascript">let text = "I love JavaScript!";
console.log(text); // "I love JavaScript!"
let newText = text.replace("JavaScript", "coding");
console.log(newText);  // "I love coding!"
</code></pre>
<p>In this example, the word <code>JavaScript</code> is found within the string and is replaced with <code>coding</code>.</p>
<p>The <code>replace()</code> method is <code>case-sensitive</code>, meaning that it will only find exact matches of the <code>searchValue</code>. For example:</p>
<pre><code class="language-javascript">let sentence = "I enjoy working with JavaScript.";
console.log(sentence);  // "I enjoy working with JavaScript."
let updatedSentence = sentence.replace("javascript", "coding");
console.log(updatedSentence);  // "I enjoy working with JavaScript."
</code></pre>
<p>Here, since <code>javascript</code> (with lowercase <code>j</code>) does not match <code>JavaScript</code> (with uppercase <code>J</code>), the replacement is not made.</p>
<p>By default, the <code>replace()</code> method will only replace the <code>first occurrence</code> of the <code>searchValue</code>. If the value appears <code>multiple</code> times in the string, only the <code>first one</code> will be replaced:</p>
<pre><code class="language-js">let phrase = "Hello, world! Welcome to the world of coding.";
console.log(phrase);  // "Hello, world! Welcome to the world of coding."
let updatedPhrase = phrase.replace("world", "universe");
console.log(updatedPhrase);  // "Hello, universe! Welcome to the world of coding."
</code></pre>
<p>Notice that only the first occurrence of <code>world</code> is replaced with <code>universe</code>.</p>
<p>The <code>replace()</code> method in JavaScript is a powerful and flexible tool for string manipulation.</p>
<p>While it's ideal for <code>straightforward</code> replacements, understanding its <code>case</code> <code>sensitivity</code> and default behavior (like replacing only the <code>first</code> occurrence) can help you use it more effectively.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/fad22e24-d4e5-410f-8ac4-87a737cabf1d.jpg" alt="" style="display:block;margin:0 auto" />

<h3><strong>How Can You Repeat a String</strong> <code>x</code> <strong>Number of Times</strong> <code>repeat()</code> <strong>method?</strong></h3>
<p>When working with JavaScript, you may encounter situations where you need to repeat a string a specific <code>number</code> of times.</p>
<p>Whether you're generating <code>repeated patterns</code> or simply <code>duplicating text</code>, the <code>repeat()</code> method provides a simple and effective way to achieve this.</p>
<p>The <code>repeat()</code> method is a built-in function in JavaScript that allows you to <code>repeat</code> a string a <code>specified number</code> of times. Here is the basic syntax:</p>
<pre><code class="language-javascript">string.repeat(count);
</code></pre>
<p><code>string</code> is the string that you want to repeat, and <code>count</code> is the number of times you want the string to be repeated. Here's an example:</p>
<pre><code class="language-javascript">let word = "Hello!";
let repeatedWord = word.repeat(3);
console.log(repeatedWord);  // "Hello!Hello!Hello!"
</code></pre>
<p>In this case, the string <code>Hello!</code> is repeated three times, resulting in <code>Hello!Hello!Hello!</code>.</p>
<p>While the <code>repeat()</code> method is useful, there are a few exceptions and limitations to keep in mind.</p>
<p>The <code>count</code> parameter must be a non-negative number. If you pass a negative number, JavaScript will throw a <code>RangeError</code>.</p>
<pre><code class="language-javascript">let word = "Test";
console.log(word.repeat(-1));  // Throws RangeError: Invalid count value
</code></pre>
<p>The <code>count</code> must be a <code>finite</code> number. If you try to repeat a string an <code>infinite</code> number of times or use <code>Infinity</code> as the count, you will also get a <code>RangeError</code>.</p>
<p>In JavaScript, <code>Infinity</code> is a special value that represents an <code>infinite</code> quantity. It's used to denote numbers that are <code>larger</code> than any finite number.</p>
<pre><code class="language-javascript">let word = "Test";
console.log(word.repeat(Infinity));  // Throws RangeError: Invalid count value
</code></pre>
<p>If the count is not an <code>integer</code> (such as a decimal like <code>2.5</code>), the <code>repeat()</code> method will round it <code>down</code> to the nearest integer.</p>
<pre><code class="language-javascript">let word = "Test";
console.log(word.repeat(2.5));  // "TestTest"
</code></pre>
<p>If you pass <code>0</code> as the count, the <code>repeat()</code> method will return an <code>empty</code> string.</p>
<pre><code class="language-javascript">let word = "Test";
console.log(word.repeat(0));  // ""
</code></pre>
<p>The <code>repeat()</code> method can simplify tasks that involve string duplication, making your code more concise and readable.</p>
<p>Whether you're generating repeated text patterns or filling a space with characters, <code>repeat()</code> can save you from writing loops or more complex code.</p>
<p>You are not limited to passing a number directly into the <code>repeat()</code> method. You can also pass a variable that stores a number value.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/6742473c-4594-47f9-a71d-d327f4a07777.jpg" alt="" style="display:block;margin:0 auto" />

<pre><code class="language-javascript">let count = 4;
let word = "Test";
let repeatedWord = word.repeat(count);
console.log(repeatedWord); // TestTestTestTest
</code></pre>
<p>In this example, the <code>count</code> variable stores the number of repetitions. This can be useful when the number of repetitions depends on user input or other dynamic values in your program.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/849ac24e-d02d-44c4-952b-b07969042dee.jpg" alt="" style="display:block;margin:0 auto" />

<div>
<div>💡</div>
<div>Now it’s your turn. Open the console, experiment with these methods, and see what JavaScript strings can really do.</div>
</div>]]></content:encoded></item><item><title><![CDATA[JavaScript Quirks That Will Make You Say “Wait, What?”]]></title><description><![CDATA[Question - 1
console.log(null === undefined) //false

Why it's false.👀

Expression*:* null === undefined

Result*:* false


Explanation
In JavaScript, both null and undefined represent "empty" values]]></description><link>https://devasif-7.hashnode.dev/javascript-quirks</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/javascript-quirks</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Tue, 08 Sep 2026 09:43:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/66e168f7-5877-4ac1-aa09-c33f2a2a7674.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3><em><strong>Question - 1</strong></em></h3>
<pre><code class="language-javascript">console.log(null === undefined) //false
</code></pre>
<p><em><strong>Why it's</strong></em> <code>false</code>.👀</p>
<ul>
<li><p><em><strong>Expression</strong></em>*:* <code>null === undefined</code></p>
</li>
<li><p><em><strong>Result</strong></em>*:* <code>false</code></p>
</li>
</ul>
<h3><em><strong>Explanation</strong></em></h3>
<p>In JavaScript, both <code>null</code> and <code>undefined</code> represent <em><strong>"empty"</strong></em> values but are <em><strong>distinct (different)</strong></em> types.</p>
<p><code>null</code> is a special <code>object</code> representing the <em><strong>intentional absence</strong></em> of a value, while <code>undefined</code> signifies that a variable has been declared but not <em><strong>assigned a value</strong></em>.</p>
<p>Despite their <em><strong>similar</strong></em> purpose, they are not <em><strong>strictly equal</strong></em> <code>(===)</code> to each other.</p>
<ul>
<li><code>null === undefined</code> evaluates to <code>false</code> because JavaScript does not perform type coercion with <code>===</code>.</li>
</ul>
<h3><em><strong>Question - 2</strong></em></h3>
<pre><code class="language-javascript">console.log(5 &gt; 3 &gt; 2) //false
</code></pre>
<p><em><strong>Why it's</strong></em> <code>false</code>.👀</p>
<ul>
<li><p><em><strong>Expression</strong></em>*:* <code>5 &gt; 3 &gt; 2</code></p>
</li>
<li><p><em><strong>Result</strong></em>*:* <code>false</code></p>
</li>
</ul>
<h3><em><strong>Explanation</strong></em></h3>
<p>At first glance, this expression may appear to be checking if <code>5</code> is greater than <code>3</code> and <code>3</code> is greater than <code>2</code>, but JavaScript evaluates it <code>left-to-right</code> due to its <em><strong>operator precedence</strong></em>.</p>
<ul>
<li><p>First, <code>5 &gt; 3</code> evaluates to <code>true</code>.</p>
</li>
<li><p>Then, <code>true &gt; 2</code> is evaluated, which in JavaScript results in <code>1 &gt; 2</code> (since <code>true</code> is <em><strong>coerced</strong></em> to <code>1</code>), which evaluates to <code>false</code>.</p>
</li>
</ul>
<p>So, <code>5 &gt; 3 &gt; 2</code> evaluates to <code>false</code>.</p>
<h3><em><strong>Question - 3</strong></em></h3>
<pre><code class="language-javascript">console.log([] === []) //false
</code></pre>
<p><em><strong>Why it's</strong></em> <code>false</code>.👀</p>
<ul>
<li><p><em><strong>Expression</strong></em>*:* <code>[] === []</code></p>
</li>
<li><p><em><strong>Result</strong></em>*:* <code>false</code></p>
</li>
</ul>
<h3><em><strong>Explanation</strong></em></h3>
<p>In JavaScript, <code>arrays</code> are <code>objects</code>. Even if <em><strong>two</strong></em> <code>arrays</code> have the same content, they are still different <code>objects</code> in memory.</p>
<ul>
<li><p>When you compare two <code>arrays</code> with <code>===</code>, you are comparing their <code>references</code>, not their <code>contents</code>.</p>
</li>
<li><p>Since <code>[]</code> and <code>[]</code> are <em><strong>different instances in memory</strong></em>, so the result is <code>false</code>.</p>
</li>
</ul>
<h3><em><strong>Question - 4</strong></em></h3>
<pre><code class="language-javascript">console.log("10" &lt; "9"); //true
</code></pre>
<p><em><strong>Why it's</strong></em> <code>true</code>.👀</p>
<ul>
<li><p><em><strong>Expression</strong></em>*:* <code>"10" &lt; "9"</code></p>
</li>
<li><p><em><strong>Result</strong></em>*:* <code>true</code></p>
</li>
</ul>
<h3><em><strong>Explanation</strong></em></h3>
<p>When JavaScript compares <code>strings</code>, it compares their <code>Unicode</code> values <code>lexicographically</code> (character by character).</p>
<ul>
<li><p><code>"10"</code> is compared to <code>"9"</code>. Since <code>"1"</code> has a lower Unicode value than <code>"9"</code>, JavaScript determines that <code>"10"</code> is less than <code>"9"</code>.</p>
</li>
<li><p>This comparison might seem <code>counterintuitive</code>, but it's due to JavaScript's <code>string</code> comparison mechanism.</p>
</li>
</ul>
<h3><em><strong>Question - 5</strong></em></h3>
<pre><code class="language-javascript">console.log(NaN === NaN);
</code></pre>
<p><em><strong>Why it's</strong></em> <code>false</code>.👀</p>
<ul>
<li><p><em><strong>Expression</strong></em>*:* <code>NaN === NaN</code></p>
</li>
<li><p><em><strong>Result</strong></em>*:* <code>false</code></p>
</li>
</ul>
<h3><em><strong>Explanation</strong></em></h3>
<p>In JavaScript, <code>NaN (Not-a-Number)</code>is a special <code>value</code> that represents an <em><strong>invalid</strong></em> <code>number</code> or the <code>result</code> of an operation that cannot produce a <code>valid number</code>.</p>
<ul>
<li><p>One of the most <em><strong>unusual aspects</strong></em> of <code>NaN</code> is that it is <em><strong>not equal to</strong></em> <code>itself</code>. This behavior exists due to the design of the <code>IEEE 754 standard</code>, which JavaScript follows for <code>floating-point arithmetic.</code></p>
</li>
<li><p>As a result, <code>NaN === NaN</code> returns <code>false</code>.</p>
</li>
</ul>
<p>To check if a value is <code>NaN</code>, use <code>Number.isNaN()</code>.</p>
<h3><em><strong>Question-6</strong></em></h3>
<pre><code class="language-javascript">console.log(true == 1);
</code></pre>
<p><em><strong>Why it's</strong></em> <code>true</code>.👀</p>
<ul>
<li><p><strong>Expression</strong>: t<code>rue == 1</code></p>
</li>
<li><p><strong>Result</strong>: <code>true</code></p>
</li>
</ul>
<h3><em><strong>Explanation</strong></em></h3>
<p>JavaScript uses <code>type coercion</code> with the <code>loose equality operator (==)</code>. When comparing <code>true</code> and <code>1</code>, JavaScript converts <code>true</code> to <code>1</code> and then compares the values.</p>
<ul>
<li>Since <code>1 == 1</code> is <code>true</code>, the overall expression evaluates to <code>true</code>.</li>
</ul>
<p>This behavior might lead to unexpected results in some cases, so it’s often recommended to use the <em><strong>strict equality operator</strong></em> (<code>===</code>) to avoid <em><strong>implicit</strong></em> type <code>coercion</code>.</p>
<h3><em><strong>Question-7</strong></em></h3>
<pre><code class="language-javascript">console.log(undefined &gt; 0);
</code></pre>
<p><em><strong>Why it's</strong></em> <code>false</code>.👀</p>
<ul>
<li><p><strong>Expression</strong>: <code>undefined &gt; 0</code></p>
</li>
<li><p><strong>Result</strong>: <code>false</code></p>
</li>
</ul>
<h3><em><strong>Explanation</strong></em></h3>
<p>When JavaScript attempts to compare <code>undefined</code> with <code>0</code>, it converts <code>undefined</code> to <code>NaN</code> <em><strong>(Not-a-Number)</strong></em>. Any comparison involving <code>NaN</code> returns <code>false</code>.</p>
<ul>
<li><code>undefined &gt; 0</code> becomes <code>NaN &gt; 0</code>, which evaluates to <code>false</code>.</li>
</ul>
<h3><em><strong>Question-8</strong></em></h3>
<pre><code class="language-javascript">console.log("5" === 5);
</code></pre>
<p><em><strong>Why it's</strong></em> <code>false</code>.👀</p>
<ul>
<li><p><strong>Expression</strong>: <code>"5" === 5</code></p>
</li>
<li><p><strong>Result</strong>: <code>false</code></p>
</li>
</ul>
<h3><em><strong>Explanation</strong></em></h3>
<p>The <em><strong>strict equality operator</strong></em> (<code>===</code>) checks <em><strong>both value and type</strong></em>. Since <code>"5"</code> is a <code>string</code> and <code>5</code> is a <code>number</code>, the <em><strong>types</strong></em> are different, and the comparison returns <code>false</code>.</p>
<ul>
<li>If you used the <em><strong>loose equality operator</strong></em> (<code>==</code>), JavaScript would perform <em><strong>type coercion</strong></em>, converting the <code>string</code> <code>"5"</code> to the <code>number</code> <code>5</code>, and the comparison would return <code>true</code>.</li>
</ul>
<h3><em><strong>Question-9</strong></em></h3>
<pre><code class="language-javascript">console.log([1, 2] == [1, 2]);
</code></pre>
<p><em><strong>Why it's</strong></em> <code>false</code>.👀</p>
<ul>
<li><p><strong>Expression</strong>: <code>[1, 2] == [1, 2]</code></p>
</li>
<li><p><strong>Result</strong>: <code>false</code></p>
</li>
</ul>
<h3>Explanation</h3>
<p>Even though both <code>arrays</code> contain the <em><strong>same</strong></em> elements, JavaScript compares <code>arrays</code> by reference, not by <code>value</code>.</p>
<ul>
<li>Since each <code>array</code> is a <em><strong>separate</strong></em> <code>object</code> in memory, their <code>references</code> are <code>different</code>, and thus the comparison returns <code>false</code>.</li>
</ul>
<p>To check if two <code>arrays</code> are <em><strong>equal</strong></em>, you must compare their contents <em><strong>element by element</strong></em>.</p>
<h3><em><strong>Question-10</strong></em></h3>
<pre><code class="language-javascript">console.log(Infinity &gt; 1000);
</code></pre>
<p><em><strong>Why it's</strong></em> <code>true</code>.👀</p>
<ul>
<li><p><strong>Expression</strong>: <code>Infinity &gt; 1000</code></p>
</li>
<li><p><strong>Result</strong>: <code>true</code></p>
</li>
</ul>
<h3><em><strong>Explanation</strong></em></h3>
<p>In JavaScript, <code>Infinity</code> represents an <code>unbounded</code>, <code>positive</code> number. It's greater than any <code>finite</code> number, including <code>1000</code>.</p>
<ul>
<li>Therefore, <code>Infinity &gt; 1000</code> evaluates to <code>true</code>.</li>
</ul>
<hr />
<h3><em><strong>IEEE Standard 754 floating-points numbers</strong></em></h3>
<p>It's a <em><strong>t</strong></em>echnical and official standard used by computers to store and do math with <em><strong>real (decimal)</strong></em> numbers.</p>
<p>Every <em><strong>IEEE 754 floating-point number</strong></em> splits memory into <em><strong>three</strong></em> parts:</p>
<ul>
<li><p><strong>Sign Bit:</strong> Tells you if the number is positive (<code>0</code>) or negative (<code>1</code>). <em><strong>Zero</strong></em> <code>(0)</code> represents a <em><strong>positive number</strong></em> while <em><strong>one</strong></em> <code>(1)</code> represents a <em><strong>negative number</strong></em>.</p>
</li>
<li><p><strong>Biased Exponent:</strong> Stores the <em><strong>power of two</strong></em>. A <em><strong>fixed bias</strong></em> number is added to the <em><strong>actual exponent</strong></em> so <em><strong>negative</strong></em> and <em><strong>positive</strong></em> powers can both be saved as <em><strong>unsigned bit</strong></em> values.</p>
</li>
<li><p><strong>Normalized Mantissa (Significand):</strong> Stores the actual <em><strong>significant</strong></em> digits. Most formats assume an invisible leading <code>1</code> before the <em><strong>binary point</strong></em> to save space.</p>
</li>
</ul>
<p><em><strong>IEEE 754</strong></em> <code>numbers</code> <em><strong>standard</strong></em> defines several sizes based on the above <em><strong>three</strong></em> components.</p>
<p><em><strong>Half-Precision</strong></em>, <em><strong>Single precision,</strong></em> <em><strong>Double precision</strong></em>, and <em><strong>Quadruple-Precision.</strong></em></p>
<h3><em><strong>Single Precision</strong></em></h3>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/6991f1af-f2d7-4b5d-aecc-da804f80d911.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>Double Precision</strong></em></h3>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/071f6310-b9e0-4c86-8a95-e40540676606.jpg" alt="" style="display:block;margin:0 auto" />

<ul>
<li><p><strong>Half-Precision (16-bit / binary16):</strong> 1 sign bit, 5 exponent bits (bias 15), 10 mantissa bits.</p>
</li>
<li><p><strong>Single-Precision (32-bit / binary32):</strong> 1 sign bit, 8 exponent bits (bias 127), 23 mantissa bits. Gives about 7 decimal digits of precision.</p>
</li>
<li><p><strong>Double-Precision (64-bit / binary64):</strong> 1 sign bit, 11 exponent bits (bias 1023), 52 mantissa bits. Gives about 16 decimal digits of precision.</p>
</li>
<li><p><strong>Quadruple-Precision (128-bit / binary128):</strong> 1 sign bit, 15 exponent bits (bias 16383), 112 mantissa bits.</p>
</li>
</ul>
<h3><em><strong>Precision</strong></em></h3>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/98d59ca5-1666-4017-8b40-8cbb84e8cade.png" alt="" style="display:block;margin:0 auto" />

<p>To demonstrate how this <em><strong>representation</strong></em> works, let us take the value <code>9.1</code>, a <em><strong>single-precision</strong></em> value. To convert this <code>number</code> to <em><strong>IEEE 754 standard</strong></em>, we have to follow the below steps.</p>
<ol>
<li><p><em>Convert the</em> <em><strong>floating-point</strong></em> <code>number</code> <em>into</em> <code>binary</code><em>.</em></p>
</li>
<li><p><em>Write the converted</em> <code>binary</code> <em>in</em> <em><strong>scientific format</strong></em>*.*</p>
</li>
<li><p>Write the <code>binary</code> <em><strong>(which is written in scientific format)</strong></em> according to <em><strong>IEEE 754 standard</strong></em>.</p>
</li>
</ol>
<blockquote>
<p>A the end, <code>9.1</code> will be converted to a <code>binary</code> with a <strong>sign bit</strong>, <strong>exponent</strong>, and a <strong>mantissa</strong>.</p>
</blockquote>
<h3><strong>1. <em>Convert the floating-point number into</em></strong> <code>binary</code><em><strong>.</strong></em></h3>
<p>Let us first convert <code>9.1</code> into <code>binary</code>. When converting it into <code>binary</code>, we need to identify <code>9</code> as an <em><strong>integral part</strong></em>, and <code>0.1</code> as the <em><strong>fractional part</strong></em> which should be converted separately.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/20fb5bb5-e211-4ff8-8758-10000664523e.jpg" alt="" style="display:block;margin:0 auto" />

<blockquote>
<p>So when converted <code>9.1</code> to binary we get <em><strong>1001.000110011001100</strong></em>…</p>
</blockquote>
<p><em>Even though</em> <code>9.1</code> <em>is an</em> <em><strong>infinite binary number</strong></em>*, we have only* <code>23</code> <em><strong>bits</strong></em> <em>to store it.</em></p>
<h3><strong>2. <em>Write the converted</em></strong> <code>binary</code> <em><strong>in scientific format.</strong></em></h3>
<p>When written <code>9.1</code> in <em><strong>scientific notation</strong></em>, the following is the result.</p>
<blockquote>
<p><strong>1.001000110011001100... x 2^3</strong></p>
</blockquote>
<h3><strong>3. <em>Write the</em></strong> <code>binary</code> <em>(which is written in scientific format) according to</em> <code>IEEE 754 standard</code><em><strong>.</strong></em></h3>
<p>Next, this number should be written in <em><strong>IEEE 754 format</strong></em>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/16990f59-1212-41d0-83e8-c877aa9c03c0.png" alt="" style="display:block;margin:0 auto" />

<p>The <em><strong>first bit</strong></em> in <em><strong>IEEE 754 Floating-point standard</strong></em> is the <em><strong>signed bit</strong></em>.</p>
<p><strong>Special Values</strong></p>
<p>The standard also <em><strong>reserves bit patterns</strong></em> for special conditions:</p>
<ul>
<li><p><strong>Infinity (±∞):</strong> Results from <em><strong>overflow</strong></em> or <em><strong>dividing</strong></em> a <em><strong>positive number by zero</strong></em>.</p>
</li>
<li><p><strong>NaN (Not a Number):</strong> Results from <em><strong>invalid operations like 0/0</strong></em>.</p>
</li>
<li><p><strong>Signed Zeros:</strong> Both <em><strong>positive</strong></em> <code>(+0)</code> and <em><strong>negative</strong></em> <code>(-0)</code> <em><strong>zero</strong></em> exist.</p>
</li>
<li><p><strong>Subnormal (De-normalized) Numbers:</strong> <em><strong>Tiny</strong></em> numbers <em><strong>close to zero</strong></em> <code>(0)</code> that lose <em><strong>precision</strong></em> to prevent <em><strong>abrupt underflow</strong></em>.</p>
</li>
</ul>
<div>
<div>💡</div>
<div><strong><em>JavaScript isn’t random, it’s following rules. Once you understand those rules, the weird behavior stops being weird.</em></strong></div>
</div>]]></content:encoded></item><item><title><![CDATA[JavaScript Fundamentals: The Concepts Beginners Often Miss]]></title><description><![CDATA[Variable declaration without a keyword in JavaScript
firsttName = "Ayan";
console.log(firsttName);

JavaScript will execute this script, even without declaring the variable with any keyword (var, let,]]></description><link>https://devasif-7.hashnode.dev/javascript-fundamentals-the-concepts-beginners-often-miss</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/javascript-fundamentals-the-concepts-beginners-often-miss</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Mon, 07 Sep 2026 09:57:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/a32fc012-c61a-43ac-a092-796ebc5d4d63.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3><em>Variable declaration without a</em> <code>keyword</code> <em>in JavaScript</em></h3>
<pre><code class="language-javascript">firsttName = "Ayan";
console.log(firsttName);
</code></pre>
<p><em><strong>JavaScript</strong></em> will execute this <em><strong>script</strong></em>, even without declaring the variable with any <em><strong>keyword</strong></em> <code>(var, let, or const)</code>.</p>
<p><em><strong>JavaScript</strong></em> doesn’t create a <strong>variable</strong> in the <code>current scope</code>. Instead <em><strong>JavaScript</strong></em> will create a <em><strong>property</strong></em> on the <em><strong>global object</strong></em>.</p>
<blockquote>
<p><em>This behavior depends entirely on whether your code is running in the</em> <em><strong>default</strong></em> <em>or</em> <em><strong>Strict Mode.</strong></em></p>
</blockquote>
<p><em><strong>Default mode</strong></em></p>
<p>If the variable is declared without a <em><strong>keyword</strong></em> inside a <code>function</code> or a <code>block</code>, <em><strong>JavaScrit</strong></em> searches up the <em><strong>scope chain</strong></em>. If <em><strong>JavaScaript</strong></em> cann't find a declaration for that <code>variable</code> name anywhere, it creates a new <em><strong>property</strong></em> on the <em><strong>global object</strong></em>.</p>
<pre><code class="language-javascript">function myFunction() {
  secretValue = "I am global!"; // No keyword used
}
myFunction();

console.log(window.secretValue); // Output: "I am global!"
console.log(secretValue);        // Output: "I am global!" 
// (Accessible anywhere)
</code></pre>
<p><em><strong>Strict Mode</strong></em></p>
<p>When strict mode is enabled in <em><strong>script</strong></em>, assigning a value to an undeclared <code>variable</code> <strong>throws a</strong> <code>ReferenceError</code> instead of silently making it <em><strong>global</strong></em>.</p>
<pre><code class="language-javascript">"use strict";

function myFunction() {
  secretValue = "I am global!"; // ❌ ReferenceError: secretValue is not defined
}
myFunction();
</code></pre>
<h3><code>Strict Mode</code> <em><strong>in JavaScript</strong></em></h3>
<p><em><strong>Strict Mode</strong></em> in JavaScript is a <em><strong>feature</strong></em> that helps <em><strong>catch</strong></em> common coding <em><strong>mistakes</strong></em> and implement a <em><strong>stricter</strong></em> <em><strong>set of rules</strong></em> to improve <em><strong>code quality</strong></em>.</p>
<p>It eliminates <em><strong>silent errors</strong></em>, prevents the use of <em><strong>unsafe actions</strong></em>, and improves <em><strong>performance optimization</strong></em> by JavaScript <em><strong>engines</strong></em>.</p>
<p><code>"use strict"</code> <em><strong>directive</strong></em></p>
<p>The <code>"use strict"</code> directive in <em><strong>JavaScript</strong></em> is used to enable <em><strong>strict mode</strong></em>. It introduces a short-list of <em><strong>variable names</strong></em> that are <em><strong>reserved</strong></em> for features that might be added to the <em><strong>language</strong></em> a bit <em><strong>later</strong></em>.</p>
<pre><code class="language-javascript">"use strict"


const interface = "video";
//Uncaught SyntaxError: Unexpected strict mode reserved word

const private = true;
//Uncaught SyntaxError: Unexpected strict mode reserved word
</code></pre>
<pre><code class="language-javascript">"use strict";

function showValue() {
    x = 10;
}
showValue()
// ReferenceError: x is not defined
</code></pre>
<ul>
<li><p>Without <code>"strict mode"</code>, <em><strong>JavaScript</strong></em> would <em><strong>implicitly</strong></em> create a property in <em><strong>global object</strong></em> at <em><strong>execution</strong></em> time.</p>
</li>
<li><p>With <code>"strict mode"</code>, this results an <em><strong>error, enforcing</strong></em> proper variable declaration.</p>
</li>
</ul>
<h3><em><strong>How to build a</strong></em> <code>string</code></h3>
<p>There is a need to add <code>string</code> in existing <code>string</code>, then you can use the <code>+=</code> operator. This is helpful when you want to <em><strong>build</strong></em> upon a <code>string</code> by adding more <em><strong>text</strong></em> to it over time.</p>
<pre><code class="language-javascript">let greeting = 'Hello';
greeting += ', John!';

console.log(greeting); // "Hello, John!"
</code></pre>
<p>In this case, the <em><strong>original string</strong></em> of <code>Hello</code> is not modified, Instead <code>greeting</code> now references the <em><strong>new string</strong></em> of <code>Hello, John!</code>.</p>
<h3><em><strong>What Is the</strong></em> <code>typeof</code> <code>null</code> <em><strong>Bug in JavaScript?</strong></em></h3>
<blockquote>
<p>There's a well-known <strong>quirk</strong> in JavaScript when it comes to <code>null</code>.</p>
</blockquote>
<p>Let's take a look at an example:</p>
<pre><code class="language-javascript">let exampleVariable = null;
console.log(typeof exampleVariable); // "object"
</code></pre>
<p>In this example, we have a variable called <code>exampleVariable</code> and have assigned it the value of <code>null</code>. But when we use the <code>typeof</code> operator, it returns the data type of it is <code>object</code>.</p>
<p>This is widely considered a <code>bug</code> in JavaScript, dating back to its early days. The reason for this behavior is rooted in the way JavaScript was originally <em><strong>designed</strong></em>.</p>
<p>When the language was <em><strong>first</strong></em> implemented, values like <code>null</code> were represented as a special type of <code>object</code>, leading to this unexpected result. Unfortunately, this has become a part of the <em><strong>language</strong></em>, and while it's confusing, it's something you'll need to be <code>aware of</code>.</p>
<h3><code>typeof</code> <em><strong>Operator</strong></em></h3>
<p>The <code>typeof</code> operator is used to check the <code>data type</code> of a <em><strong>variable</strong></em>. It returns a <code>string</code> indicating the <code>type</code> of the variable.</p>
<pre><code class="language-javascript">let age = 25;
console.log(typeof age); // "number"

let isLoggedIn = true;
console.log(typeof isLoggedIn); // "boolean"
</code></pre>
<h3><em><strong>What Is the</strong></em> <code>prompt()</code> <em><strong>Method, and How Does It Work?</strong></em></h3>
<pre><code class="language-javascript">prompt(message, default);
</code></pre>
<p>The <code>prompt()</code> method is an important part of <em><strong>JavaScript's interaction</strong></em> with the user. It’s one of the simplest ways to <em><strong>get input</strong></em> from a user through a small <em><strong>pop-up dialog box</strong></em>.</p>
<p>The <code>prompt()</code> method takes <code>two</code> arguments: The <code>first</code> one is the <em><strong>message</strong></em> which will appear <code>inside</code> the <code>dialog box</code>, typically <code>prompting</code> the user to enter information.</p>
<p>And the <code>second</code> one is a <code>default</code> value which is optional and will fill the input field initially.</p>
<p>So, what exactly does the <code>prompt()</code> method do? It opens a <em><strong>dialog box</strong></em> that asks the user for <em><strong>some input</strong></em>, and then it <code>returns</code> the <em><strong>text</strong></em> entered by the <em><strong>user</strong></em> as a <code>string</code>.</p>
<p><strong>Here's an example of how it works.</strong></p>
<pre><code class="language-html">&lt;button id="prompt-btn"&gt;Show Prompt&lt;/button&gt;
&lt;p id="output"&gt;&lt;/p&gt;
&lt;script src="index.js"&gt;&lt;/script&gt;
</code></pre>
<pre><code class="language-javascript">const btn = document.getElementById("prompt-btn");
const output = document.getElementById("output");
btn.addEventListener("click", () =&gt; {
  const userName = prompt("What is your name?", "Guest");
  output.textContent = "Hello, " + userName + "!";
});
</code></pre>
<p>In this example, when the <em><strong>user clicks on the button</strong></em>, the <code>prompt()</code> method displays a <em><strong>dialog box</strong></em> with the <em><strong>message</strong></em> <code>What is your name?</code> and an <em><strong>input field</strong></em> that initially contains the value <code>Guest</code>.</p>
<p>If the <em><strong>user types their name and presses "OK"</strong></em>, the <code>userName</code> variable will store the <em><strong>entered value</strong></em>.</p>
<p>If the <strong><em>user presses "Cancel"</em>,</strong> the <code>userName</code> variable will be set to <code>null</code>.</p>
<p><code>null</code> signifies that the <em><strong>user</strong></em> did not provide any <em><strong>input</strong></em>. The output paragraph will then display a <em><strong>greeting message</strong></em> using the provided name or <code>null</code> if the user <em><strong>canceled</strong></em>.</p>
<p>You will learn techniques to avoid displaying <code>null</code> when a user cancels the prompt in future blogs.</p>
<div>
<div>💡</div>
<div>Keep in mind that the <code>prompt()</code> method will <code>halt</code> <code>(stop)</code> the <strong><em>execution</em></strong> of the <strong><em>script</em></strong> until the <strong><em>user interacts</em></strong> with the <strong><em>dialog box</em></strong>.</div>
</div>

<p>This means the <em><strong>rest(reamining)</strong></em> of your JavaScript code won’t <code>run</code> until the user either provides <code>input</code> and clicks <code>"OK"</code>, or <code>cancels</code> the <code>prompt</code>.</p>
<p>One other <em><strong>point</strong></em> to consider is that while <code>prompt()</code> is useful for <em><strong>quick testing</strong></em> or <em><strong>small applications</strong></em>, it's generally <code>avoided</code> in <em><strong>modern</strong></em>, <em><strong>complex web applications</strong></em> due to its <code>disruptive</code> nature and <em><strong>inconsistent</strong></em> behavior across different <em><strong>browsers</strong></em>.</p>
<h3><em><strong>What Is</strong></em> <code>ASCII</code></h3>
<p>In programming, understanding how characters are represented as <em><strong>numbers</strong></em> is fundamental. This is where <em><strong>ASCII</strong></em> comes in.</p>
<p><em><strong>ASCII</strong></em>, short for <em><strong>American Standard Code for Information Interchange</strong></em>, is a character <em><strong>encoding (convert into a coded form)</strong></em> <em><strong>standard</strong></em> used in computers to represent <em><strong>text</strong></em>. It assigns a <em><strong>numeric</strong></em> value to <em><strong>each character</strong></em>, which is universally recognized by <em><strong>machines</strong></em>.</p>
<div>
<div>💡</div>
<div>You’ve learned the essentials, but JavaScript still has a few surprises waiting for you. See you in the next one! 🚀</div>
</div>]]></content:encoded></item><item><title><![CDATA[How JavaScript Makes Decisions: A Beginner's Guide to Conditionals]]></title><description><![CDATA[Conditional statements
Conditional statements in JavaScript allow your code to make decisions and execute different blocks of code based on whether a condition is true or false.

There are 4 primary w]]></description><link>https://devasif-7.hashnode.dev/how-javascript-makes-decisions-a-beginner-s-guide-to-conditionals</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/how-javascript-makes-decisions-a-beginner-s-guide-to-conditionals</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Sun, 06 Sep 2026 10:35:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/0bb0d6ec-b95f-4bb1-a91c-67fbb1e787b3.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3><em><strong>Conditional statements</strong></em></h3>
<p><em><strong>Conditional statements</strong></em> <em>in JavaScript</em> <em><strong>allow your code to make decisions and execute different blocks of code based on whether a condition is true or false.</strong></em></p>
<blockquote>
<p>There are <strong>4</strong> primary ways to write conditional logic in JavaScript:</p>
</blockquote>
<ol>
<li><em><strong>The</strong></em> <code>if</code><em><strong>,</strong></em> <code>else if</code><em><strong>, and</strong></em> <code>else</code> <em><strong>Statements</strong></em></li>
</ol>
<p>This is the <em><strong>most common</strong></em> way to handle sequential conditions. JavaScript evaluates the conditions from <em><strong>top</strong></em> to <em><strong>bottom</strong></em> and runs the block of the first condition that is <em><strong>truthy</strong></em>.</p>
<p>The <code>if...else</code> statement executes a statement if a specified condition is <code>truthy</code>. If the condition is <code>falsy</code>, another statement in the optional <em><strong>else</strong></em> clause will be executed.</p>
<pre><code class="language-javascript">let score = 85;

if (score &gt;= 90) {
  console.log("Grade: A"); // Runs if score is 90 or above
} else if (score &gt;= 80) {
  console.log("Grade: B"); // Runs if score is between 80 and 89
} else {
  console.log("Grade: C"); // Runs if all previous conditions fail
}
</code></pre>
<div>
<div>💡</div>
<div><em>JavaScript try to </em><strong><em>coerce</em></strong><em> any value into a </em><code>boolean</code><em>. No matter what we put inside </em><code>()</code><em> parenthesis, if it is not a </em><code>boolean</code><em> , JavaScript will try to convert it to a </em><code>boolean</code><em> .</em></div>
</div>

<ol>
<li><em><strong>The Ternary Operator (</strong></em><code>? :</code><em><strong>)</strong></em></li>
</ol>
<p>The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator"><em><strong>Ternary Operator</strong></em></a> is a compact, one-line shorthand for a simple <code>if...else</code> statement. It is ideal for quickly assigning variables or choosing between two values.</p>
<p><strong>Syntax:</strong> <code>condition ? value_if_true : value_if_false;</code></p>
<pre><code class="language-javascript">let age = 20;
let message = age &gt;= 18 ? "Allowed" : "Denied";

console.log(message); // Output: Allowed
</code></pre>
<ol>
<li><em><strong>The</strong></em> <code>switch</code> <em><strong>Statement</strong></em></li>
</ol>
<p>A <a href="https://javascript.info/switch"><em><strong>Switch Case</strong></em></a> statement checks a <em><strong>single</strong></em> variable against <em><strong>multiple</strong></em> exact values. It is cleaner and more readable than <em><strong>multiple</strong></em> <code>else if</code> chains when comparing a variable to fixed options.</p>
<p><em><strong>Note:</strong></em> <em>Always remember the</em> <code>break</code> <em>keyword to stop execution from falling through to the next case.</em></p>
<pre><code class="language-javascript">let pet = "dog";

switch (pet) {
  case "cat":
    console.log("Meow!");
    break;
  case "dog":
    console.log("Woof!"); // This case matches and executes
    break;
  default:
    console.log("Unknown animal"); // Runs if no cases match
}
</code></pre>
<ol>
<li><em><strong>Logical Operators Shorthand (</strong></em><code>&amp;&amp;</code> <em><strong>and</strong></em> <code>||</code><em><strong>)</strong></em></li>
</ol>
<p>You can use <em><strong>short-circuit evaluation</strong></em> as a quick conditional statement:</p>
<ul>
<li><p><code>&amp;&amp;</code> <strong>(AND):</strong> Runs the <em><strong>right-hand</strong></em> code <em><strong>only if</strong></em> the <em><strong>left-hand condition</strong></em> evaluates to <code>true</code>.</p>
</li>
<li><p><code>||</code> <strong>(OR):</strong> Provides a fallback value <em><strong>if</strong></em> the <em><strong>left-hand condition</strong></em> is <code>false</code>.</p>
</li>
</ul>
<pre><code class="language-javascript">let isLoggedIn = true;
// Renders the message only if logged in
isLoggedIn &amp;&amp; console.log("Welcome back!"); 

let username = "";
// Falls back to "Guest" because username is an empty string (falsy)
let displayName = username || "Guest"; 
</code></pre>
<blockquote>
<p>In JavaScript <code>&amp;&amp;</code> and <code>||</code> operators basically doesn't only return <code>true</code> or <code>false</code> but also return returned <strong>operand</strong> based on <strong>short-circuiting</strong> evaluation.</p>
</blockquote>
<h3><code>(!)</code> <em><strong>NOT operator</strong></em></h3>
<div>
<div>💡</div>
<div><code>(!)</code>operator works on only <strong><em>one</em></strong> <code>boolean</code> value and just <strong><em>inverts (reverse)</em></strong> it. It has precedence <strong><em>over</em></strong> <code>AND</code> &amp; <code>OR</code> operators.</div>
</div>

<pre><code class="language-javascript">console.log(!false); //true
console.log(!true); //false
</code></pre>
<h3><em><strong>Short - circuit evaluation</strong></em></h3>
<p><em>JavaScript evaluates logical expressions</em> <em><strong>left to right</strong></em> <em>and it stopped it when the result is</em> <em><strong>determined (completed)</strong></em><em>.</em></p>
<p><em>When it stopped the evaluation that moment is called</em> <em><strong>short - circuit</strong></em><em>.</em></p>
<h3><em><strong>Types of short - circuit</strong></em></h3>
<p><code>&amp;&amp;</code> <em><strong>case</strong></em></p>
<ul>
<li><p><em>In given condition, if the</em> <em><strong>left</strong></em> <em>operand is</em> <code>truthy</code><em>,</em> <code>&amp;&amp;</code> <em>will return</em> <em><strong>right</strong></em> <em>value</em></p>
</li>
<li><p><em>In given condition, if the</em> <em><strong>left</strong></em> <em>operand is</em> <code>falsy</code><em>,</em> <code>&amp;&amp;</code> <em>will return</em> <em><strong>left</strong></em> <em>value (Don't check rigth)</em></p>
</li>
</ul>
<pre><code class="language-javascript">// 1. if left operand is truthy, return right
console.log(true &amp;&amp; 10); // 10
console.log("Hi" &amp;&amp; "Bye"); // Bye


// 2. if left operand is falsy, return that
console.log(false &amp;&amp; 10); // false
console.log(0 &amp;&amp; "Hello"); // 0
</code></pre>
<p><code>||</code> <em><strong>case</strong></em></p>
<ul>
<li><p><em>In given condition, if the</em> <em><strong>left</strong></em> <em>operand is</em> <code>truthy</code><em>,</em> <code>||</code> <em>will return</em> <em><strong>left</strong></em> <em>value (Don't check right)</em></p>
</li>
<li><p><em>In given condition, if the</em> <em><strong>left</strong></em> <em>operand is</em> <code>falsy</code><em>,</em> <code>||</code> <em>will return</em> <em><strong>right</strong></em> <em>value (Whether it's</em> <code>truthy</code> <em>or</em> <code>falsy</code><em>)</em></p>
</li>
</ul>
<pre><code class="language-javascript">// 1. if left operand is truthy, return left
console.log(true || 10); // true
console.log("Hi" || "Bye"); // Bye


// 2. if left operand is falsy, return right
console.log(false || 10); // 10
console.log(0 || "Hello"); // Hello
</code></pre>
<h3><em><strong>Best Practices to Keep in Mind</strong></em></h3>
<ul>
<li><p><strong>Use Strict Equality</strong> <code>(===)</code><strong>:</strong> Always use <code>===</code> instead of <code>==</code> to prevent hidden <em><strong>type-coercion</strong></em> bugs (e.g., <code>5 == "5"</code> is <code>true</code>, but <code>5 === "5"</code> is <code>false</code>).</p>
</li>
<li><p><strong>Keep Braces:</strong> Always wrap your <code>if</code> statements in curly braces <code>{}</code> even if they are only one line long to improve overall codebase safety.</p>
</li>
<li><p><strong>Beware of</strong> <code>"Falsy"</code> <strong>Values:</strong> JavaScript treats <code>0</code>, <code>""</code> (empty string), <code>null</code>, <code>undefined</code>, <code>NaN</code>, and <code>false</code> automatically as <code>false</code> inside conditions. Everything else is <code>truthy</code>.</p>
</li>
</ul>
<div>
<div>💡</div>
<div><strong><em>JavaScript can decide what to do. Next, we’ll teach it how to do it repeatedly.</em></strong></div>
</div>]]></content:encoded></item><item><title><![CDATA[JavaScript Fundamentals That Finally Make Sense]]></title><description><![CDATA[Template literals (Template strings)
Template literals are literals delimited (determine the limit or boundary) with back-ticks `` (define string here) characters for declaring strings, allowing for m]]></description><link>https://devasif-7.hashnode.dev/javascript-fundamentals</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/javascript-fundamentals</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Sat, 05 Sep 2026 14:34:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/413e137d-dc94-4566-9563-1d2fe17628e0.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2><em><strong>Template literals (Template strings)</strong></em></h2>
<p><em><strong>Template literals</strong></em> are <em><strong>literals delimited</strong></em> <em>(determine the limit or boundary)</em> with <em><strong>back-ticks ``</strong></em> (<code>define string here</code>) characters for declaring <em><strong>strings</strong></em>, allowing for <em><strong>multi-line strings</strong></em>, <em><strong>string interpolation</strong></em> with <em><strong>embedded expressions.</strong></em></p>
<pre><code class="language-javascript">let name = 'Ayan'; 
console.log(`Hello ${name}`); // Hello Ayan
</code></pre>
<div>
<div>💡</div>
<div><strong><em>Embedding variables:</em></strong> <em>Template literals</em> like <code>Hello ${name}</code> insert <em>variable values</em> directly into <strong><em>strings</em></strong>, producing output such as <code>hello Ayan</code>.</div>
</div>

<p><em><strong>Cleaner concatenation:</strong></em> They avoid using <code>+</code>, making <em><strong>string</strong></em> creation more readable and easier to write.</p>
<blockquote>
<p><strong>Template literals take all the</strong> <code>number</code> <strong>values and converts them into</strong> <code>string</code><strong>.</strong></p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/dfec36da-8315-4cb8-97eb-5ae9aa1de703.jpg" alt="" style="display:block;margin:0 auto" />

<h2><code>Truthy</code> <em><strong>and</strong></em> <code>Falsy</code> <em><strong>values</strong></em></h2>
<div>
<div>💡</div>
<div><strong><em>Those values can be called as </em></strong><code>true</code><strong><em> or </em></strong><code>false</code><strong><em> in </em></strong><code>Boolean</code><strong><em> context.</em></strong></div>
</div>

<h3><em><strong>falsy values</strong></em></h3>
<p>A <em><strong>falsy</strong></em> value is a value that is considered <code>false</code> when encountered in a <code>Boolean</code> context.</p>
<div>
<div>💡</div>
<div><strong><em>falsy values</em></strong><em> are values that are not exactly </em><code>false</code><em>, but will become </em><code>false</code><em> when we try to convert them into a </em><code>boolean</code><em>.</em></div>
</div>

<p>JavaScript uses <em><strong>type coversion</strong></em> (explicit conversion) to <em><strong>coerce</strong></em> (implicit convert) any value to a <code>Boolean</code> in contexts that require it, such as <code>conditional</code> and <code>loops</code>.</p>
<pre><code class="language-javascript">false, undefined, NaN, null, "", 0, 0n, -0
</code></pre>
<h3><em><strong>truthy values</strong></em></h3>
<p>In JavaScript a <strong>truthy</strong> value is a value that is considered <strong>true</strong> when encountered in a <strong>Boolean</strong> context.</p>
<pre><code class="language-javascript">true, 1, "Ayan"
</code></pre>
<blockquote>
<p>Except <strong>falsy</strong> all values are <strong>truthy</strong>.</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/45723fbf-92da-4934-a37e-45027f29bf9d.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em>Type coercion</em></h3>
<p>Type <em><strong>coercion</strong></em> is the <em><strong>automatic or implicit conversion</strong></em> of values from <em><strong>one</strong></em> data type to <em><strong>another</strong></em> (such as <code>strings</code> to <code>numbers</code>).</p>
<pre><code class="language-javascript">const value1 = "5";
const value2 = 9;
let sum = value1 + value2;

console.log(sum); // 59
</code></pre>
<div>
<div>💡</div>
<div><em>It happens whenever </em><strong><em>an operator</em></strong><em> is dealing with </em><strong><em>two values</em></strong><em> that have </em><strong><em>different type</em></strong><em>, behind the scene JavaScript </em><strong><em>convert one</em></strong><em> of the values to </em><strong><em>match</em></strong><em> the other value.</em></div>
</div>

<p><em><strong>Explanation</strong></em></p>
<p>JavaScript has <em><strong>coerced</strong></em> the <code>9</code> from a <code>number</code> into a <code>string</code> and then <em><strong>concatenated</strong></em> the two values together, resulting in a <code>string</code> of <code>59</code>.</p>
<p>JavaScript had a choice between a <code>string</code> or a <code>number</code> and decided to use a <code>string</code>.</p>
<p><em><strong>Why?</strong></em> Because it’s defined in it’s <code>engine</code>.</p>
<p><em>The compiler could have</em> <em><strong>coerced</strong></em> <em>the</em> <code>5</code> <em>into a</em> <code>number</code> <em>and returned a</em> <em><strong>sum</strong></em> <em>of</em> <code>14</code><em>, but it did not.</em></p>
<p><em>To return this result, you'd have to</em> <em><strong>explicitly</strong></em> <em><strong>convert</strong></em> <em>the</em> <code>5</code> <em>to a</em> <code>number</code> <em>using the</em> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number"><em>Number()</em></a> <em>method:</em></p>
<pre><code class="language-javascript">console.log(Number("9" + 5); // 14
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/2f92b957-2f17-4f38-9342-fb28ba91d59f.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>How Type Coercion Works?</strong></em></h3>
<p>In JavaScript, <em><strong>type coercion</strong></em> mainly occurs in the <em><strong>three</strong></em> ways:</p>
<p><em><strong>String Coercion</strong></em></p>
<p><em>It occurs when the</em> <code>string</code> <em>is combined with the</em> <em><strong>non-string</strong></em> <em>using</em> <code>(+)</code><em>. JavaScript converts</em> <code>numbers</code> <em>and</em> <code>booleans</code> <em>into</em> <code>strings</code> <em>before concatenation.</em></p>
<pre><code class="language-javascript">console.log("5" + 2); //52
console.log("5" + true); //5true
</code></pre>
<ul>
<li><p><em>The number</em> <code>2</code> <em>is</em> <em><strong>coerced</strong></em> <em>to a</em> <code>string</code> <em>and then concatenated with the</em> <code>string "5"</code><em>, resulting in</em> <code>"52"</code><em>.</em></p>
</li>
<li><p><em>The</em> <code>boolean true</code> <em>is</em> <em><strong>coerced</strong></em> <em>into the</em> <code>string "true"</code><em>, and the</em> <em><strong>two</strong></em> <code>strings</code> <em>are concatenated.</em></p>
</li>
</ul>
<p><em><strong>Number Coercion</strong></em></p>
<p><em>In the</em> <code>number</code> <em><strong>coercion</strong></em>*, JavaScript converts the* <code>string</code> <em>into a</em> <code>number</code> <em>before operating.</em></p>
<pre><code class="language-javascript">console.log("5" - 2); //3
console.log("5" * 2); //10
console.log("10" / "2"); //5
</code></pre>
<div>
<div>💡</div>
<div><em>With </em><code>+</code><em> operator, JavaScript performs </em><strong><em>concatenation</em></strong><em>. Except </em><code>+</code><em> operator, JavaScript performs </em><strong><em>arithmetic operations</em></strong><em>.</em></div>
</div>

<p><em><strong>Boolean Coercion</strong></em></p>
<p><em>JavaScript treats the</em> <code>truthy / true</code> <em>value as</em> <code>1</code> <em>and the</em> <code>falsy / false</code> <em>value as</em> <code>0</code><em>.</em></p>
<pre><code class="language-javascript">console.log(Boolean("hello")); //true
console.log(Boolean(0)); //false
console.log(Boolean([])); //true
</code></pre>
<blockquote>
<p><strong>Non-empty</strong> <code>strings</code> are <strong>coerced</strong> to <code>true</code>, while <code>0</code> is <strong>coerced</strong> to <code>false</code>.</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/9418b068-2d26-41e0-b365-749d77545d63.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>Common Issues of Type Coercion</strong></em></h3>
<p><em><strong>Comparing Different Data Types</strong></em></p>
<p><em><strong>Comparison Operator</strong></em> <code>(==)</code><em>, allows</em> <em><strong>coercion</strong></em> <em>due to which the</em> <em><strong>unexpected conversions</strong></em> <em>occur. To avoid this, we should use the</em> <em><strong>strict equality</strong></em> <code>(===)</code> <em>operator.</em></p>
<pre><code class="language-javascript">console.log(0 == "0"); //true
console.log(0 == false); //true
console.log(" " + 0 == 0); //true
</code></pre>
<p><em><strong>Operations on null and undefined</strong></em></p>
<p><code>Null</code> <em>and</em> <code>undefined</code> <em>behave unexpectedly.</em></p>
<pre><code class="language-javascript">console.log(null == undefined); //true
console.log(null === undefined); //false
console.log(null + 1); //1
</code></pre>
<p><code>NaN</code> <em><strong>Comparisons</strong></em></p>
<p><code>NaN</code> <em>is not equal to</em> <em><strong>itself</strong></em>*, so checking with* <code>isNaN()</code> <em>is the best way to detect it.</em></p>
<pre><code class="language-javascript">console.log(NaN == NaN); //false
console.log(isNaN(NaN)); //true
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/64f412cb-9c0d-4fb6-a6dc-d450c2109a3e.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>Best Practices to Avoid Type Coercion Issues</strong></em></h3>
<p><em><strong>Use</strong></em> <code>===</code> <em><strong>Instead of</strong></em> <code>==</code></p>
<p><em>When we use</em> <em><strong>strict equality</strong></em> <code>(===)</code><em>, instead of the</em> <em><strong>comparison operator / loose equality</strong></em> <code>(==)</code><em>, it prevents unnecessary types of</em> <em><strong>coercion</strong></em>*.*</p>
<pre><code class="language-javascript">console.log(5 === "5"); //false
</code></pre>
<p><code>===</code> <em>ensures no</em> <em><strong>implicit type conversion</strong></em> <em>occurs and both values must be of the</em> <em><strong>same</strong></em> <em>type.</em></p>
<p><em><strong>Use Explicit Conversion</strong></em></p>
<p><em><strong>Explicit conversion</strong></em> <em>converts the value</em> <em><strong>manually</strong></em> <em>due to which there are fewer chances of errors in the code.</em></p>
<pre><code class="language-javascript">console.log(Number("123")); //123
</code></pre>
<p><em>This ensures that you're working with the</em> <em><strong>correct type</strong></em>*, reducing the chance of errors during operations.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/ed028f20-e53b-4bb8-96eb-ec49b706fe2b.jpg" alt="" style="display:block;margin:0 auto" />

<p><em><strong>Avoid False Value Confusion</strong></em></p>
<blockquote>
<p>Always check for <code>null</code>, <code>undefined</code>, or <code>“”</code> <strong>empty strings</strong> explicitly.</p>
</blockquote>
<pre><code class="language-javascript">if (value !== null &amp;&amp; value !== undefined) {
    console.log("Value exists");
}
</code></pre>
<blockquote>
<p>This ensures that only <strong>non-null</strong> and <strong>defined</strong> values are considered valid.</p>
</blockquote>
<p><em><strong>Use</strong></em> <code>parseInt()</code> <em><strong>and</strong></em> <code>parseFloat()</code> <em><strong>for</strong></em> <code>Number</code> <em><strong>Conversion</strong></em></p>
<pre><code class="language-javascript">console.log(parseInt("42px")); //42
console.log(parseFloat("3.14abc")); //3.14
</code></pre>
<blockquote>
<p>This will parse the <strong>number part of a string</strong>, ensuring a <strong>valid</strong> numeric conversion.</p>
</blockquote>
<p><em><strong>Handle</strong></em> <code>NaN</code> <em><strong>Properly</strong></em></p>
<div>
<div>💡</div>
<div><em>Use </em><code>isNaN()</code><em> to check if a value is </em><code>NaN</code><em> instead of comparing it directly.</em></div>
</div>

<pre><code class="language-javascript">if (isNaN(value)) {
    console.log("Invalid number");
}
</code></pre>
<blockquote>
<p>This ensures you're correctly detecting <strong>NaN</strong> and handling it appropriately.</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/0a984d83-f200-4334-9b7a-3a1375efb42b.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>Type conversion</strong></em></h3>
<p><em><strong>Manually</strong></em> or <em><strong>explicitly</strong></em> convert the <em><strong>type</strong></em> of a value from <em><strong>one data-type</strong></em> to <em><strong>another</strong></em>.</p>
<p><em><strong>Original value doesn’t converted.</strong></em></p>
<p><em>JavaScript can only convert to</em> <em><strong>three</strong></em> <em>types. we can convert to a</em> <code>number</code><em>, to a</em> <code>string</code><em>, or to a</em> <code>boolean</code><em>.</em></p>
<pre><code class="language-javascript">const inputYear = "1996";
console.log(Number(inputYear), inputYear);
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/448df7c0-21e0-4347-81a3-cfaea3da2c9b.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>Function</strong></em></h3>
<p>The fundamental <em><strong>building block</strong></em> of real-world JavaScript applications are <code>functions</code>. It’s a reusable piece of code.</p>
<p><em><strong>function declaration</strong></em></p>
<pre><code class="language-javascript">function logger() {//function-body
  console.log("My name is Ayan");
}
//calling or running or invoking function
logger();
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/da979edf-5cce-4955-ab7b-c456b2f99c99.jpg" alt="" style="display:block;margin:0 auto" />

<p>We can <strong>pass</strong> data into a <code>function</code>. It can return data as well. We can pass <code>parameters</code> to the function, the parameters are like <strong>variables</strong> that are <strong>specific</strong> only to this function and they will get defined <code>once</code> we <code>call</code> the <code>function</code>.</p>
<p>These are like <strong>placeholders</strong> that actually replaced by <code>arguments</code> that passed to the function.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/6d839598-2577-4c17-8f29-d63ead73f1cc.jpg" alt="" style="display:block;margin:0 auto" />

<pre><code class="language-javascript">function calcAge1(birthYear) {
  return 2026 - birthYear;
}

const age = calcAge1(2015);
console.log("Ayan is", age, "years old.");
</code></pre>
<blockquote>
<p><em><strong>This function is called function declaration.</strong></em></p>
</blockquote>
<h3><em>return</em> statement</h3>
<ul>
<li><p>The <code>return</code> <em><strong>statement</strong></em> is used to send a result back from a function.</p>
</li>
<li><p>When <code>return</code> executes, the function <code>stops</code> running at that point.</p>
</li>
<li><p>The <code>returned</code> value can be stored in a <code>variable</code> or used directly.</p>
</li>
</ul>
<pre><code class="language-javascript">function fruitProcessor(apples, oranges) {//(apples,oranges) are Parameters

  const juice = `Juice with ${apples} apples and ${oranges} oranges.`;
  return juice;
}

const appleJuice = fruitProcessor(2, 0); //(2, 0)--&gt; Arguments
console.log(appleJuice);

const applesOrangesJuice = fruitProcessor(3, 5);
console.log(applesOrangesJuice);
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/e52c6e8c-8701-4ba1-8dbc-af697029979d.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em>Function expression &amp; declaration</em></h3>
<p>In JavaScript there are different way of writing <code>functions</code> and each type of <strong>function</strong>, works in a slightly different way.</p>
<h3><em><strong>function declaration / named function</strong></em></h3>
<p><em>A function that has its</em> <code>own</code> <em>name when declared. It’s easy to reuse and debug because the</em> <code>name</code> <em>shows up in</em> <code>error messages</code> <em>or</em> <code>stack traces</code><em>.</em></p>
<pre><code class="language-javascript">function calcAge1(birthYear) {
  return 2026 - birthYear;
}

const age = calcAge1(2015);
console.log("Ayan is", age, "years old.");
</code></pre>
<h3><em><strong>function expression* / *Anonymous function</strong></em></h3>
<p><em>An</em> <code>anonymous</code> <em>function is a function defined without an</em> <code>explicit name.</code> <em>It is commonly used as a</em> <code>callback</code> <em>or assigned to a</em> <code>variable</code><em>. It can be</em> <em><strong>named</strong></em> <em>or</em> <em><strong>anonymous</strong></em><em>.</em></p>
<pre><code class="language-javascript">const calcAge2 = function (birtYear) {
  //Anonymous function or function expression
  return 2026 - birtYear;
};
const ageAltamash = calcAge2(2005);
console.log("Altamash is", ageAltamash, "years old.");

/*
function (birtYear) {
  return 2026 - birtYear;
}; It's the expression and produces a vlue
*/
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/0824d7e3-275e-4aa5-9c45-a9200dc38481.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>Hoisting</strong></em></h3>
<p><em>Functions in JavaScript just are actually</em> <em><strong>values</strong></em><em>. function</em> <code>declarations</code> <em>can called before they defined in the code. Internally this happens because of the process</em> <code>hoisting</code><em>.</em></p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/46c5cb56-0899-4e83-a067-37ae6f76bc44.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>(=&gt;) arrow function</strong></em></h3>
<p><em><strong>An</strong></em> <code>arrow function</code> <em><strong>is simply a special form of function</strong></em> <code>expression</code> <em><strong>that is shorter and therefore faster to write. It was introduced in</strong></em> <code>ES6</code><em><strong>. They don’t their</strong></em> <code>this</code> <em><strong>binding.</strong></em></p>
<pre><code class="language-javascript">const yearsUntilRetirement = (birtYear, firstName) =&gt; {
  const age = 2026 - birtYear;
  const retirement = 60 - age;
  return `${firstName} retires in ${retirement} years.`;
};

const retirementYears = yearsUntilRetirement(1980, "Jacob");
console.log(retirementYears);
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/001d69ca-1b08-40c3-9be7-56ea978d64a0.jpg" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>this keyword</strong></em></h3>
<p><code>this</code> refers the <strong>current context. It means the</strong> <code>object</code> <strong>is calling this function.</strong></p>
<h3><em><strong>calling one function from inside another function</strong></em></h3>
<pre><code class="language-javascript">function fruitProcessor(apples, oranges) {
  const juice = `Juice with ${apples} apples and ${oranges} oranges.`;
  return juice;
}
</code></pre>
<p><em>This function is like a</em> <code>fruit processor</code> <em>which received a certain number of</em> <code>apples</code> <em>and a certain number of</em> <code>oranges</code><em>. And then based on that it basically produced and returned juice to us. Simulate to calling one function from inside another function.</em></p>
<p><code>fruit processor</code> <em>can only make juice with smaller fruit pieces. And so before making the juice the fruit processor now needs another machine that first cuts the fruits that we give it into multiple smaller pieces.</em></p>
<pre><code class="language-javascript">function cutFruitPieces(fruit) {
  return fruit * 4;
}

function fruitProcessor(apples, oranges) {
  const applePieces = cutFruitPieces(apples);
  const orangePieces = cutFruitPieces(oranges);
  const juice = `Juice with ${applePieces} piece of apple and ${orangePieces} piece of orange.`;
  return juice;
}
console.log(fruitProcessor(2, 3));
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/d5cdb2bc-514e-43b4-a3cf-2be98662ec3c.jpg" alt="" style="display:block;margin:0 auto" />

<div>
<div>💡</div>
<div><strong><em>Which JavaScript concept do you find the most confusing? Share it in the comments, and let’s learn together.</em></strong></div>
</div>]]></content:encoded></item><item><title><![CDATA[JavaScript as a programming language]]></title><description><![CDATA[💡
software is nothing more than data plus instructions.


What is the programming language?
Programming language is just a tool that allows us to write code that will instruct a computer to do someth]]></description><link>https://devasif-7.hashnode.dev/javascript-as-a-programming-language</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/javascript-as-a-programming-language</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Sat, 05 Sep 2026 11:09:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/249d5b13-5430-4ed5-981e-58f56f606648.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div>
<div>💡</div>
<div><strong><em>software is nothing more than data plus instructions.</em></strong></div>
</div>

<h3>What is the programming language?</h3>
<p>Programming language is just a tool that allows us to write code that will instruct a computer to do something.</p>
<h3>What is the JavaScript?</h3>
<p><code>JavaScript</code> is a <code>high level</code> language, which means that we don’t have to think about a lot of <code>complex stuff</code> such managing <code>computer’s memory</code> while it runs the program.</p>
<p>There are a lot of so-called <code>abstractions</code> over all these small details that we don’t want worry about. And this makes the language a lot easier to write and to learn.</p>
<p>It’s Object Oriented(Based on objects for storing most kind of data) and multi-paradigm(Can use different programming styles) language.</p>
<div>
<div>💡</div>
<div><strong><em>JavaScript is case-sensitive</em></strong></div>
</div>

<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/3907e934-c514-4164-abb7-a2f1d5398cf9.webp" alt="" style="display:block;margin:0 auto" />

<h3><strong>Popularity of JavaScript</strong></h3>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/cf022e2a-2ef2-4b94-8e85-dfec23e692ab.webp" alt="" style="display:block;margin:0 auto" />

<h3><strong>Dynamic Typing</strong></h3>
<p>JavaScript has a feature called <code>dynamic typing</code>. It means when you create a <code>new variable</code>, you don’t have to <code>manually define the data type</code> of the value that it contains.</p>
<p>JavaScript automatically determines the <code>data type</code> of the value when it’s stored into a variable. In JavaScript that <strong>value</strong> has a <strong>type</strong> not <strong>variable</strong>.</p>
<div>
<div>💡</div>
<div><strong><em>It’s simply mean that we can easily change the </em></strong><code>type</code><strong><em> of a value that is hold by a variable.</em></strong></div>
</div>

<h3><em><strong>Programming Paradigms in JavaScript</strong></em></h3>
<p><em>JavaScript supports both</em> <code>imperative</code> <em>and</em> <code>declarative</code> <em>programming styles:</em></p>
<ul>
<li><p><strong>Imperative Programming</strong> : <em>Focuses on how to perform tasks by controlling the</em> <code>flow</code> <em>of computation.</em> This includes approaches like <code>procedural</code> and <code>object-oriented</code> programming, often using constructs like <code>async/await</code> to handle asynchronous actions.</p>
</li>
<li><p><strong>Declarative Programming</strong> : <em>Focuses on what should be done rather than how it’s done.</em> It emphasizes describing the desired result, such as with <code>arrow functions</code>, without detailing the steps to achieve it.</p>
</li>
</ul>
<div>
<div>💡</div>
<div><strong><em>variable, data types, conditionals, loops, functions, and objects are the LEGO of any programming language.</em></strong></div>
</div>

<hr />
<h3><strong>Variables</strong></h3>
<p>Variable can be said as <em><strong>container / label</strong></em> to contain some value. To store some value in <em><strong>memory,</strong></em> the variable is used for it.</p>
<ul>
<li><p>Variables can be declared using <code>var</code>, <code>let</code>, or <code>const</code></p>
</li>
<li><p>JavaScript is <em><strong>dynamically typed</strong></em>, so <code>types of values</code> are decided at <em><strong>runtime</strong></em>.</p>
</li>
<li><p>You don’t need to specify a <em><strong>data type</strong></em> when creating a variable.</p>
</li>
<li><p><code>var (function and global scoped), let and const (local scoped).</code></p>
</li>
<li><p><code>var</code> can be <code>re-declared</code> in the same scope, but <code>let</code> and <code>const</code> cannot be re-declared.</p>
</li>
</ul>
<pre><code class="language-javascript">var x = 10;
var x = 20; // Allowed

let y = 30;
let y = 40; // SyntaxError

const z = 50;
const z = 60; // SyntaxError
</code></pre>
<div>
<div>💡</div>
<div>We can change the elements of <code>array</code> or <code>objects</code> even if declared as <code>const</code>. <code>How?</code> Because their reference is saved in <code>stack</code> while value in <code>heap</code>.</div>
</div>

<pre><code class="language-javascript">let name = "JS";
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/2221fba6-d57d-4ea2-826a-f30f1c3492be.png" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>Rules for Naming Variables</strong></em></h3>
<p>When naming variables in JavaScript, follow these rules</p>
<ul>
<li><p>Variable names must begin with a <code>letter (A to Z or a to z)</code>, <code>underscore (_)</code>, or <code>dollar sign ($)</code>.</p>
</li>
<li><p><em><strong>Subsequent</strong></em> (after that) characters can be <em><strong>letters</strong></em>, <em><strong>numbers</strong></em>, <em><strong>underscores</strong></em>, or <em><strong>dollar signs</strong></em>.</p>
</li>
<li><p>Variable names are <em><strong>case-sensitive</strong></em> (e.g., <code>age</code> and <code>Age</code> are different variables).</p>
</li>
<li><p>Reserved keywords (like <code>function</code>, <code>class</code>, <code>return</code>, etc.) cannot be used as variable names.</p>
</li>
</ul>
<h3><em><strong>Data Types</strong></em></h3>
<p><em>It’s an attribute (quality) that identifies (recognizes) a piece of data and instructs (tells) a computer system on how to interpret (explain) its value is called a</em> <code>data type</code><em>.</em></p>
<div>
<div>💡</div>
<div><strong><em>Each data type has its own methods and operations that control how it can be used.</em></strong></div>
</div>

<blockquote>
<p>The <strong>data</strong> has type (e.g. <strong>number</strong>, <strong>string</strong>, <strong>boolean</strong> etc.) is <strong>data type</strong>.</p>
</blockquote>
<div>
<div>💡</div>
<div><em>Primitive data types in JavaScript represent </em><code>simple</code><em>, </em><code>immutable</code><em> values stored directly in </em><code>memory</code><em>, ensuring efficiency in both memory usage and performance.</em></div>
</div>

<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/76a38a6d-5e1b-479e-a041-403e26f3123d.webp" alt="" style="display:block;margin:0 auto" />

<h3><em><strong>Data-types in JavaScript</strong></em></h3>
<h3>1. <code>Number</code></h3>
<div>
<div>💡</div>
<div><em>The</em><a target="_self" rel="noopener noreferrer" class="text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer notion-link-token notion-focusable-token notion-enable-hover" href="https://www.geeksforgeeks.org/javascript/javascript-numbers/" style="pointer-events:none"><strong><em><u> Number</u></em></strong></a><em> data type in JavaScript includes both </em><code>integers</code><em> and </em><code>floating-point</code><em> numbers. Special values like </em><code>Infinity</code><em>, </em><code>-Infinity</code><em>, and </em><code>NaN</code><em> represent </em><code>infinite</code><em> values and computational errors, respectively.</em></div>
</div>

<pre><code class="language-javascript">let n1 = 2;
console.log(n1)

let n2 = 1.3;
console.log(n2)

let n3 = Infinity;
console.log(n3)

let n4 = 'something here too' / 2;
console.log(n4)
</code></pre>
<h3>2. <code>String</code></h3>
<div>
<div>💡</div>
<div><em>A </em><a target="_self" rel="noopener noreferrer" class="text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer notion-link-token notion-focusable-token notion-enable-hover" href="https://www.geeksforgeeks.org/javascript/javascript-strings/" style="pointer-events:none"><strong><em><u>String</u></em></strong></a><em> in JavaScript is a series of characters that are surrounded by </em><code>quotes</code><em>. There are three types of </em><code>quotes</code><em> in JavaScript, which are </em><code>‘string’</code><em>, </em><code>”string”</code><em>, and </em><code>`string`</code>. <strong><em>(Single quotes, Double quotes, &amp; Backticks)</em></strong>.</div>
</div>

<pre><code class="language-javascript">let s1 = "Hello There";
console.log(s1); 

let s2 = 'Single quotes work fine';
console.log(s2); 

let s3 = `can embed ${s1}`;
console.log(s3);
</code></pre>
<h3>3. <code>Boolean</code></h3>
<div>
<div>💡</div>
<div><em>The </em><a target="_self" rel="noopener noreferrer" class="text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer notion-link-token notion-focusable-token notion-enable-hover" href="https://www.geeksforgeeks.org/javascript/javascript-boolean/" style="pointer-events:none"><strong><em><u>boolean</u></em></strong></a><em> type has only </em><code>two</code><em> values i.e. </em><code>true</code><em> and </em><code>false</code><em>.</em></div>
</div>

<pre><code class="language-javascript">let b1 = true;
console.log(b1);  

let b2 = false;
console.log(b2);
</code></pre>
<h3>4. <code>null</code></h3>
<div>
<div>💡</div>
<div><em>The special </em><a target="_self" rel="noopener noreferrer" class="text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer notion-link-token notion-focusable-token notion-enable-hover" href="https://www.geeksforgeeks.org/javascript/null-in-javascript/" style="pointer-events:none"><strong><em><u>null value</u></em></strong></a><em> does not belong to any of the default data types. It forms a separate type of its own which contains only the </em><code>null</code><em> value.</em></div>
</div>

<pre><code class="language-javascript">const middleName = null;
//Explicitly define empty. null can be said as empty
</code></pre>
<h3>5. <code>undefined</code></h3>
<div>
<div>💡</div>
<div><em>A variable that has been </em><strong><em>declared</em></strong><em> but not </em><strong><em>initialized</em></strong><em> with a value is automatically assigned the </em><a target="_self" rel="noopener noreferrer" class="text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer notion-link-token notion-focusable-token notion-enable-hover" href="https://www.geeksforgeeks.org/javascript/undefined-vs-null-in-javascript/" style="pointer-events:none"><strong><em><u>undefined</u></em></strong></a><em> value. It means the variable </em><strong><em>exists</em></strong><em>, but it has no value </em><strong><em>assigned</em></strong><em> to it.</em></div>
</div>

<pre><code class="language-javascript">const firstName; 
//Value (undefine) taken by a variable that is not yet define.
</code></pre>
<h3>6. <code>BigInt (Introduced in ES2020)</code></h3>
<div>
<div>💡</div>
<div><a target="_self" rel="noopener noreferrer nofollow" class="text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer" href="https://www.geeksforgeeks.org/javascript/javascript-bigint/" style="pointer-events:none"><strong><em>BigInt</em></strong></a><em> is a </em><code>built-in object</code><em> that provides a way to represent </em><strong><em>whole</em></strong><em> numbers greater than </em><code>253</code><em>. The largest number that JavaScript can reliably represent with the </em><code>Number</code><em> primitive is </em><code>253</code><em>, which is represented by the </em><code>MAX_SAFE_INTEGER</code><em> constant.</em></div>
</div>

<pre><code class="language-javascript">let b = BigInt("0b1010101001010101001111111111111111");
let largeNumber = 1234576454525657535n;
console.log(b);
console.log(largeNumber);
</code></pre>
<h3>7. <code>Symbol (Introduced in ES6)</code></h3>
<div>
<div>💡</div>
<div><a target="_self" rel="noopener noreferrer" class="text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer notion-link-token notion-focusable-token notion-enable-hover" href="https://www.geeksforgeeks.org/javascript/javascript-symbol-method/" style="pointer-events:none"><strong><em><u>Symbols</u></em></strong></a><em>, introduced in </em><code>ES6</code><em>, are </em><strong><em>unique</em></strong><em> and </em><strong><em>immutable</em></strong><em> primitive values used as </em><code>identifiers</code><em> for </em><code>object</code><em> properties. They help create </em><code>unique keys</code><em> in </em><code>objects</code><em>, preventing conflicts with other properties.</em></div>
</div>

<pre><code class="language-javascript">let s1 = Symbol("JS");
let s2 = Symbol("JS");
console.log(s1 == s2); //false
</code></pre>
<h3>8. <code>object (most important)</code></h3>
<div>
<div>💡</div>
<div></div>
</div>

<pre><code class="language-javascript">let obj = {
    type: "Company",
    location: "Noida"
}
console.log(obj.type)
</code></pre>
<div>
<div>💡</div>
<div><strong><em>In JavaScript other than primitive data type is </em></strong><code>object</code><strong><em>. Primitive data types are </em></strong><code>7</code></div>
</div>

<h3><em><strong>Comments</strong></em></h3>
<p>In programming, we use <em><strong>comments</strong></em> to literally comment code or <em><strong>deactivate</strong></em> code without deleting it. We can do comments in two types.</p>
<p><em><strong>JS engine</strong></em> doesn't parse these comments, they are for <em><strong>developers</strong></em> and explain the code.</p>
<ol>
<li><p><em>Single line comment</em> <code>(//….)</code></p>
</li>
<li><p><em>Multi line comment</em> <code>(/* … */)</code></p>
</li>
</ol>
<pre><code class="language-javascript">//let javascript = "FUN!";

/*
if (true) {
    var x = 10;
    let y = 20;
}

console.log(x);  
console.log(y);  
*/
</code></pre>
<h3><em><strong>Operators in JavaScript</strong></em></h3>
<p><em>JavaScript operators are</em> <code>symbols</code> <em>or</em> <code>keywords</code> <em>used to perform</em> <code>operations</code> <em>on</em> <code>values</code> <em>and</em> <code>variables</code><em>.</em></p>
<p><em>They are the</em> <code>building blocks</code> <em>of JavaScript expressions and can manipulate data in various ways.</em></p>
<p><em><strong>1.Arithmetic Operators</strong></em> <code>(+, -, , /, %, *)</code></p>
<div>
<div>💡</div>
<div><a target="_self" rel="noopener noreferrer" class="text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer notion-link-token notion-focusable-token notion-enable-hover" href="https://www.geeksforgeeks.org/javascript/javascript-arithmetic-operators/" style="pointer-events:none"><strong><em><u>Arithmetic Operators</u></em></strong></a><em> perform mathematical calculations like </em><code>addition</code><em>, </em><code>subtraction</code><em>, </em><code>multiplication</code><em>, etc.</em></div>
</div>

<pre><code class="language-javascript">const sum = 5 + 3; // Addition
const diff = 10 - 2; // Subtraction
const prodcut = 4 * 2; // Multiplication
const quotient = 8 / 2; // Division
const exponent = 4 ** 2; //Exponentiation
const remainder = 4 % 2; //modulous
console.log(sum, diff, prodcut, quotient, exponent, remainder);
</code></pre>
<div>
<div>💡</div>
<div><strong><em>Important :- </em></strong><code>**</code><strong><em> Exponent operator, it raised the second operand as a power of first operand. </em></strong><code>%</code><strong><em> Modulus operator, it's used to calculate the remainder.</em></strong></div>
</div>

<p><em><strong>2.* *Comparison / Relational Operators</strong></em> <code>(==, !=, ===, !==, &gt;, &lt;, &gt;=, &lt;=, in, insteadof)</code></p>
<div>
<div>💡</div>
<div><em>Used to produce </em><code>boolean</code><em> value based on the comparison result. These are useful for making </em><strong><em>decisions</em></strong><em> in conditional statements. They are used to compare its operands and determine the relationship between them.</em></div>
</div>

<pre><code class="language-javascript">console.log(10 &gt; 5);
console.log(10 === "10");
</code></pre>
<ul>
<li><p><code>&gt;</code> checks if the left value is greater than the right.</p>
</li>
<li><p><code>===</code> checks for strict equality (both type and value).</p>
</li>
<li><p>Other operators include <code>&lt;, &lt;=, &gt;=,</code> and <code>!==</code>.</p>
</li>
</ul>
<pre><code class="language-javascript">const obj = { length: 10 };
console.log("length" in obj);
console.log([] instanceof Array);
</code></pre>
<ul>
<li><p><code>in</code> checks if a property exists in an <code>object</code>.</p>
</li>
<li><p><code>instanceof</code> checks if an <code>object</code> is an instance of a <code>constructor</code>.</p>
</li>
</ul>
<p><em><strong>3.Assignment Operators</strong></em> <code>(=, +=, -=, *=, /=, %=)</code></p>
<div>
<div>💡</div>
<div><a target="_self" rel="noopener noreferrer" class="text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer notion-link-token notion-focusable-token notion-enable-hover" href="https://www.geeksforgeeks.org/javascript/javascript-assignment-operators/" style="pointer-events:none"><strong><em><u>Assignment operators</u></em></strong></a><em> are used to assign values to variables. They can also perform operations like </em><strong><em>addition</em></strong><em> or </em><strong><em>multiplication</em></strong><em> while assigning the value. </em><code>+=</code><em> These called </em><strong><em>compound</em></strong><em> assignment operators.</em></div>
</div>

<pre><code class="language-javascript">let n = 10;
n += 5;
n *= 2;
console.log(n);
</code></pre>
<ul>
<li><p><code>=</code> assigns a value to a variable.</p>
</li>
<li><p><code>+=</code> adds and assigns the result to the variable.</p>
</li>
<li><p><code>=</code> multiplies and assigns the result to the variable.</p>
</li>
</ul>
<p><em><strong>4. Ternary Operator</strong></em> <code>(condition? “true”: “false”)</code></p>
<div>
<div>💡</div>
<div><strong><em>It is a shorthand for conditional statements. It takes three operands.</em></strong></div>
</div>

<pre><code class="language-javascript">const age = 18;
const status = age &gt;= 18 ? "Adult" : "Minor";
console.log(status);
</code></pre>
<blockquote>
<p><strong>condition ? expression1 : expression2</strong> evaluates <strong>expression1</strong> if the condition is <strong>true</strong>, otherwise evaluates <strong>expression2</strong>.</p>
</blockquote>
<p><em>5.</em> <em><strong>Logical Operators</strong></em> <code>(&amp;&amp;, ||, !)</code></p>
<div>
<div>💡</div>
<div><strong><em>These are mainly used to perform the logical operations that determine the equality or difference between the values.</em></strong></div>
</div>

<pre><code class="language-javascript">console.log(true &amp;&amp; 10);     //output: 10
console.log("Hi" || "Bye"); //output: Hi
console.log(!true);        //output: false
</code></pre>
<blockquote>
<p>JavaScript doen't always evaluate the entire expression.</p>
</blockquote>
<p>As a <em><strong>logical expression</strong></em> is evaluated <em><strong>left to right ,</strong></em> JavaScript stops <em><strong>e</strong></em>xecution as soon as the <em><strong>final outcome</strong></em> is determined***.*** If the result is clear***,*** javascript <em><strong>short-circuits (stop)</strong></em> the process and ignores the remaining expressions or function calls on the <em><strong>right.</strong></em></p>
<blockquote>
<p>Logical operators in JavaScript don't just return <strong>true</strong> or <strong>false -</strong> they actually return the <strong>value</strong> of the operand where the evaluation stopped.</p>
</blockquote>
<ul>
<li><p><code>falsy &amp;&amp; anything</code> is <em><strong>short-circuit</strong></em> evaluated to the <code>falsy</code> value.</p>
</li>
<li><p><code>truthy || anything</code> is <em><strong>short-circuit</strong></em> evaluated to the <code>truthy</code> value.</p>
</li>
<li><p><code>nonNullish ?? anything</code> is <em><strong>short-circuit</strong></em> evaluated to the <code>non-nullish</code> value.</p>
</li>
</ul>
<p><em><strong>6. Unary Operators</strong></em> <code>(++, —, +, -, typeof, void, delete)</code></p>
<blockquote>
<p>These operators, operate on a single operand.</p>
</blockquote>
<pre><code class="language-javascript">let x = 5;

console.log(+x);
console.log(-x);

console.log(++x);
console.log(--x);
</code></pre>
<ul>
<li><p><code>+</code> converts a value to a <code>number</code>.</p>
</li>
<li><p><code>-</code> negates a value (changes its <code>sign</code>).</p>
</li>
</ul>
<p>++ increments a value by <code>1</code>.</p>
<p>-- decrements a value by <code>1</code>.</p>
<p><code>typeof</code> returns the <code>data type</code> of a variable.</p>
<p><code>delete</code> removes a property from an <code>object</code>.</p>
<hr />
<div>
<div>💡</div>
<div><strong><em>This is just the beginning. You’ve met JavaScript, now it’s time to see what you can build with it. 🚀</em></strong></div>
</div>]]></content:encoded></item><item><title><![CDATA[Virtual DOM Under the Hood: A Beginner's Guide]]></title><description><![CDATA[Whenever you want to learn React, You have probably heard about the Virtual DOM

Without virtual DOM
Suppose, you have a list that contains 10 items, but for some reason you have to update only one it]]></description><link>https://devasif-7.hashnode.dev/virtual-dom-under-the-hood-a-beginner-s-guide</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/virtual-dom-under-the-hood-a-beginner-s-guide</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[React]]></category><category><![CDATA[virtual dom]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Thu, 07 May 2026 18:03:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/ed0e54b5-f9e4-4d32-b312-db6c8e608cfd.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Whenever you want to learn React, You have probably heard about the Virtual DOM</p>
</blockquote>
<h1>Without virtual DOM</h1>
<p>Suppose, you have a list that contains 10 items, but for some reason you have to update only one item of the list, most JavaScript's framework and plain JavaScript as well will <strong>re-render /</strong> <strong>rebuild / repaint</strong> the entire list. That is <strong>10 times</strong> more work than necessary. <em><strong>Virtual DOM only updates what is necessary.</strong></em></p>
<h2>Real DOM vs Virtual DOM</h2>
<h3>Real DOM(Document Object Model)</h3>
<p>It's a programming interface (<em><strong>interface - A set of rules)</strong></em> in browser. <strong>DOM</strong> connects web pages (HTML, CSS, or XML etc.) to scripts or programming languages by representing the structre of a web <strong>page / document</strong> in memory. DOM often misunderstood that it's the core JavaScript. HTML, SVG, or XML documents are modled (created) as objects.</p>
<p><strong>DOM</strong> represents a document as <strong>tree of nodes</strong> and all nodes contains / are <strong>objects.</strong> It has methods and properties to manipulate (change the structure, style, and content) it.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/0fbb3b35-c242-4c8e-953c-2cf1c43f3854.png" alt="" style="display:block;margin:0 auto" />

<h3>Virtual DOM</h3>
<p>It'a lightweight copy of <em><strong>Actual / Real DOM</strong></em> in memory. It's nothing but a JavaScript object that perfectly mirros / copies the real DOM maintained by react.</p>
<p><strong>Working of Virtual DOM</strong></p>
<p>Whan an update occurs, React manages it through a systemtic process called <strong>Reconsiliation</strong>.</p>
<p>Step are mentioned How virtual DOM works.</p>
<p><strong>Initial Render:-</strong> When the app starts, React also creates a virtual DOM that <strong>mirros / copies</strong> the actual / real DOM.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/6aef581d-03f7-431a-adb5-545d12bf0d80.png" alt="" style="display:block;margin:0 auto" />

<p><strong>State Change:-</strong> When the states or props change in the app, React creates new virtual DOM and re-renders the updated components in the virtual DOM. These changes do not immediately impact the real DOM.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/496f476c-e4af-495d-8f39-b76e5c69eaec.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Diffing Algorithm:-</strong> When differences / updates are identified, React compares the new Virtual DOM with the previous version of virtual DOM to exactly which elements have changed.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/244cbf5b-8b30-47f2-a64f-f1f05d0894bf.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Reconsiliation / Minimal updates applied:-</strong> Based on the differences identified, React determines the most efficient way to update the real DOM. Only the parts of the real DOM that need to be updated are changed, rather than re-rendering the entire UI. This selective updating is quick and performant.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/531d38e5-e4cb-4326-b13f-467104176b65.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Update to Real DOM:-</strong> Finally, React applies the necessary changes to the real DOM. This might involve adding, removing, or updating elements based on the differences detected.</p>
<img src="https://cdn.hashnode.com/uploads/covers/695114b01f48b622b5631972/0018780b-6b49-4996-9db6-fc43cbe8a34f.png" alt="" style="display:block;margin:0 auto" />

<div>
<div>💡</div>
<div>Real DOM and Virtual DOM are both in memory</div>
</div>

<details>
<summary>Addons about React</summary>
<p>virtual DOM is an abstraction / simplified version of DOM implemented by React, not a browser feature. Browsers have the real DOM, The virtual DOM exists solely in memory within React and is used to optimize updates to the real DOM.</p>
</details>

<p>Let's take the example-</p>
<pre><code class="language-javascript">import { useState } from 'react';

function App() {
 const [count, setCount] = useState(0);

 return (
   &lt;div&gt;
     &lt;h1&gt;Counter: {count}&lt;/h1&gt;
     &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;/button&gt;
   &lt;/div&gt;
 );
}

export default App;
</code></pre>
<p>The virtual DOM representation</p>
<pre><code class="language-json">{
 "type": "div",
 "props": {},
 "children": [
   {
     "type": "h1",
     "props": {},
     "children": [
       {
         "type": "TEXT_ELEMENT",
         "props": {
           "nodeValue": "Counter: 0"
         }
       }
     ]
   },
   {
     "type": "button",
     "props": {
       "onClick": "setCount(count + 1)"
     },
     "children": [
       {
         "type": "TEXT_ELEMENT",
         "props": {
           "nodeValue": "Increment"
         }
       }
     ]
   }
 ]
}
</code></pre>
<p>When the <code>Increase</code> button is clicked once, only the <code>h1</code> element is changed:</p>
<pre><code class="language-json">{
 "type": "h1",
 "props": {},
 "children": [
   {
     "type": "TEXT_ELEMENT",
     "props": {
       "nodeValue": "Counter: 1"
     }
   }
 ]
}
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Understanding the Inner Workings of a Web Browser: A Beginner's Guide]]></title><description><![CDATA[Daily, we use browsers like Chrome, Safari, Firefox, etc. Have you ever wondered what happens after you type a URL and press Enter in a split second? We see a beautiful-looking website. How does a browser turn lines of code into images, text, and col...]]></description><link>https://devasif-7.hashnode.dev/understanding-the-inner-workings-of-a-web-browser-a-beginners-guide</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/understanding-the-inner-workings-of-a-web-browser-a-beginners-guide</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Sat, 31 Jan 2026 21:49:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769865624857/cff9b044-2bfb-45fd-8d6e-ecbfed6a92ab.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Daily, we use browsers like Chrome, Safari, Firefox, etc. Have you ever wondered <strong><em>what happens after you type a URL and press Enter in a split second?</em></strong> We see a beautiful-looking website. How does a browser turn lines of code into images, text, and colors?</p>
<p>In this blog, we will learn what happens under the hood of the browser. What the browser actually is, and the components of a browser. Differences among the browser engines, and a step-by-step process of how the browser renders(displays) a website.</p>
<h2 id="heading-what-is-a-browser-actually"><strong>What is a browser actually?</strong></h2>
<p>Most people think a browser is just the <strong>user-agent</strong>(app) that opens a website on the internet.</p>
<p>Technically, a browser is a software application designed to <strong>locate, retrieve, and display</strong> content from the <strong>World Wide Web</strong>. It acts as a translator. It takes languages that computers understand (<strong>HTML, CSS, JavaScript</strong>) and translates them into a visual format that humans can understand.</p>
<h3 id="heading-main-components-of-a-browser"><strong>Main components of a browser</strong></h3>
<p>A browser is not just one big program; it is made of several working components. Here are the most important ones:</p>
<ol>
<li><p><strong>The User Interface (UI):</strong> This is the part you interact with, the address bar, back/forward buttons, bookmarks menu, and the home button.</p>
</li>
<li><p><strong>The Browser Engine:</strong> This is the manager. It handles communication between the UI and the rendering engine. (<strong>Gecko, Chromium</strong>, etc.)</p>
</li>
<li><p><strong>The Rendering Engine:</strong> This is the artist. It is responsible for rendering/displaying the requested content. If you request an HTML page, the rendering engine parses the HTML and CSS and shows the content on the screen.</p>
</li>
<li><p><strong>Networking:</strong> This part handles internet communication, like sending HTTP requests to servers to get a response/code.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769893468731/c7e723a1-1c11-43eb-a6d4-ab0faf5f6205.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-browser-engine-vs-rendering-engine"><strong>Browser Engine vs Rendering Engine</strong></h3>
<p>It is easy to get these two mixed up, so let's simplify:</p>
<ul>
<li><p><strong>Browser Engine:</strong> Handles the logic. It listens to what you click in the UI and tells the rendering engine what to do.</p>
</li>
<li><p><strong>Rendering Engine:</strong> Handles the visuals. It reads the code and draws the page.</p>
<ul>
<li>Examples<em>:</em> Chrome uses <strong>Blink</strong>, Safari uses <strong>WebKit</strong>, and Firefox uses <strong>Gecko</strong>.</li>
</ul>
</li>
</ul>
<h2 id="heading-what-is-parsing"><strong>What is Parsing</strong></h2>
<p>Before we dive into how <strong>HTML</strong> works, we need to understand <strong>Parsing</strong>.</p>
<p>Parsing simply means reading text and converting it into something meaningful that the computer can use.</p>
<p><strong>Think of a simple math problem:</strong> <code>2 + 2</code></p>
<p>When you read this, your brain doesn't just see three random symbols.</p>
<ol>
<li><p>You identify the number <code>2</code>.</p>
</li>
<li><p>You identify the operator <code>+</code>.</p>
</li>
<li><p>You understand the rule: "add them together."</p>
</li>
<li><p>You get the result <code>4</code>.</p>
</li>
</ol>
<p>Browsers do the same thing. They read a tag like <code>&lt;h1&gt;Hello&lt;/h1&gt;</code>, understand that <code>h1</code> means Big Heading, and then process it to look like a heading.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769894839943/c71391cb-eb55-4d46-aaf6-19ee83bf70e9.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769895100148/13186064-fb11-4b5e-b1a9-76c44bc9b770.png" alt class="image--center mx-auto" /></p>
<p>Now, let's see how the browser renders a website step-by-step.</p>
<h3 id="heading-1-networking-fetching-the-data"><strong>1. Networking: Fetching the data</strong></h3>
<p>Everything starts when you type a URL. The browser's <strong>Networking</strong> layer sends a request to the server (using DNS and TCP, which we discussed in previous blogs).</p>
<blockquote>
<p><strong>Browser request: DNS → IP → TCP → (TLS) → HTTP → Network → Server</strong></p>
</blockquote>
<p>I have explained DNS and TCP in detail: <a target="_blank" href="https://devasif-7.hashnode.dev/">Read Blogs</a></p>
<p>The server replies/responds with the raw files: HTML, CSS, and images.</p>
<h3 id="heading-2-html-parsing-and-dom-creation"><strong>2. HTML Parsing and DOM creation</strong></h3>
<p>The Rendering Engine receives the raw HTML text. It starts parsing (reading) it line by line.</p>
<p>It converts these tags into a tree structure called the <strong>DOM (Document Object Model)</strong>.</p>
<ul>
<li><p><strong>HTML:</strong> The text file.</p>
</li>
<li><p><strong>DOM:</strong> The object structure in the browser's memory.</p>
</li>
</ul>
<p>Your HTML looks like this:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Hello, I'm HTML<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>The Markup Language<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>The DOM will look like a tree where <code>div</code> is the parent and <code>h1</code> is the child. Without the DOM, JavaScript would not be able to interact with the page.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769895912296/e8c0fbb7-22c2-4a75-b1c0-9ed4d6bfe11a.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-3-css-parsing-and-cssom-creation"><strong>3. CSS Parsing and CSSOM creation</strong></h3>
<p>While the browser builds the DOM, it also finds CSS links. It reads the CSS and builds a similar tree structure called the <strong>CSSOM (CSS Object Model)</strong>.</p>
<p>This tree tells the browser: The <code>h1</code> should be red, or the <code>div</code> should be 100px wide.</p>
<h3 id="heading-4-how-dom-and-cssom-come-together-the-render-tree"><strong>4. How DOM and CSSOM come together (The Render Tree)</strong></h3>
<p>Now the browser has two separate trees:</p>
<ol>
<li><p><strong>DOM</strong> (Content)</p>
</li>
<li><p><strong>CSSOM</strong> (Style)</p>
</li>
</ol>
<p>It combines them into a <strong>Render Tree</strong>.</p>
<p>The Render Tree only contains things that will actually appear on the screen.</p>
<blockquote>
<p><em>Note:</em> If you have an element with <code>display: none</code>, it exists in the DOM, but it will <strong>not</strong> be in the Render Tree.</p>
</blockquote>
<h3 id="heading-5-layout-reflow"><strong>5. Layout (Reflow)</strong></h3>
<p>Now the browser knows what to show (Render Tree), but it doesn't know where to put it.</p>
<p>This step is called <strong>Layout</strong>.</p>
<p>The browser calculates the exact geometry, position, height, and width of every element based on your screen size.</p>
<ul>
<li>Ideally, the browser decides: This image goes 50px from the top, and this text wraps around it.</li>
</ul>
<h3 id="heading-6-painting-and-displayrendering"><strong>6. Painting and Display/Rendering</strong></h3>
<p>Finally, we have the <strong>Paint</strong> stage.</p>
<p>The browser takes all those calculations and fills in the pixels on your screen. It draws the text, colors the backgrounds, and displays the images.</p>
<p>This happens incredibly fast, usually in milliseconds, so it feels instant to you.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>A browser is a complex machine that acts as a bridge between code and visuals. It doesn't just show a website, it fetches raw text, builds internal trees (DOM and CSSOM), calculates math (Layout), and finally paints pixels.</p>
<p>Understanding this flow helps you realize that performance isn't just about internet speed, it's about how efficiently your code can go through these steps without blocking the browser.</p>
]]></content:encoded></item><item><title><![CDATA[Mastering CSS Selectors for Precise Element Targeting]]></title><description><![CDATA[Consider the process of painting a house. You can't just splash/throw color everywhere and expect it to look good. You have to be specific in selecting a bold red for the door, a clean white for the walls, and a different shade for the windows.
In we...]]></description><link>https://devasif-7.hashnode.dev/mastering-css-selectors-for-precise-element-targeting</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/mastering-css-selectors-for-precise-element-targeting</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[CSS]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Sat, 31 Jan 2026 12:10:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769859268940/ae2330fe-385e-4b56-a9a8-3226e844b3b3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Consider the process of painting a house. You can't just splash/throw color everywhere and expect it to look good. You have to be specific in selecting a bold red for the door, a clean white for the walls, and a different shade for the windows.</p>
<p>In web development, <strong>HTML</strong> is the house structure, and <strong>CSS</strong> is the paint. But to apply that paint correctly, you need a way to point to specific parts of the <strong>HTML</strong> and say, Style this part, but not that part. This is exactly what <strong>CSS Selectors</strong> do.</p>
<p>In this blog, we’ll break down exactly why <strong>CSS</strong> selectors are so important. We’ll walk through the basics of <strong>Element</strong>, <strong>Class</strong>, and <strong>ID</strong> selectors, look at how to group them to keep your code clean, and explain how <strong>descendant</strong> selectors work. Finally, we’ll clear up the confusion around '<strong>Specificity</strong>' - basically, deciding which rule wins when two styles <strong>clash/conflicts</strong>.</p>
<h2 id="heading-why-css-selectors-are-needed"><strong>Why CSS Selectors are Needed</strong></h2>
<p>Imagine if we didn't have selectors, <strong>CSS</strong> would be uselessly broad. If you changed the font size, it applied to every single word on your website, <strong>headers</strong>, <strong>footers</strong>, <strong>buttons</strong>, and <strong>paragraphs</strong> alike. It would be a mess.</p>
<p>Selectors allow us to be precise. They act as a bridge between the <strong>HTML</strong> content and the <strong>CSS</strong> styling rules. They tell the browser exactly which <strong>HTML</strong> elements should receive which styles.</p>
<h3 id="heading-the-element-selector"><strong>The Element Selector</strong></h3>
<p>This is the most basic way to style things. An <strong>Element Selector</strong> targets <strong>all</strong> instances(targeted elements) of a specific HTML tag.</p>
<p>If you want every paragraph <code>&lt;p&gt;</code> on your site to have blue text, you use this.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: blue;
}
</code></pre>
<ul>
<li><p><strong>What it does:</strong> Every single paragraph on the page is styled blue.</p>
</li>
<li><p><strong>When to use:</strong> When you want a consistent default style for a standard tag (like setting the font for all text).</p>
</li>
</ul>
<h3 id="heading-the-class-selector"><strong>The Class Selector</strong></h3>
<p>Sometimes, you don't want every paragraph to look the same. Maybe you want some paragraphs to be warnings with red text. This is where the <strong>Class Selector</strong> comes in.</p>
<p>You can give any <strong>HTML</strong> element a <code>class</code> attribute (e.g., <code>&lt;p class="warning"&gt;</code>). In CSS, you select it using a <strong>dot</strong> (<code>.</code>).</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-class">.warning</span> {
  <span class="hljs-attribute">color</span>: red;
  <span class="hljs-attribute">font-weight</span>: bold;
}
</code></pre>
<ul>
<li><p><strong>What it does:</strong> Only elements with <code>class="warning"</code> will become red and bold. Normal paragraphs stay the same.</p>
</li>
<li><p><strong>When to use:</strong> This is your workhorse. Use classes when you want to apply the same style to <strong>many</strong> different elements across the page.</p>
</li>
</ul>
<h3 id="heading-the-id-selector"><strong>The ID Selector</strong></h3>
<p>While classes are for groups, IDs are for individuals(unique). An <strong>ID Selector</strong> targets a single, unique element on the page.</p>
<p>You give an <strong>HTML</strong> element an <code>id</code> attribute (e.g., <code>&lt;div id="main-header"&gt;</code>). In CSS, you select it using a <strong>hash</strong> (<code>#</code>).</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-id">#main-header</span> {
  <span class="hljs-attribute">background-color</span>: black;
  <span class="hljs-attribute">color</span>: white;
}
</code></pre>
<ul>
<li><p><strong>What it does:</strong> It will find the one element with that specific ID and style it.</p>
</li>
<li><p><strong>When to use:</strong> Use this sparingly(sharply). It is best for unique sections that appear only once per page, like a <strong>Header</strong>, <strong>Footer</strong>, or a specific <strong>Logo container.</strong></p>
</li>
</ul>
<h3 id="heading-group-selectors"><strong>Group Selectors</strong></h3>
<p>As you write more <strong>CSS</strong>, you might notice you are repeating yourself.</p>
<p>Maybe you want your <code>h1</code>, <code>h2</code>, and <code>p</code> tags to all use the same font. Instead of writing three separate rules, you can use a <strong>Group Selector</strong>. You simply separate the selectors with a comma <code>(,).</code></p>
<p><strong>Example:</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-tag">h1</span>, <span class="hljs-selector-tag">h2</span>, <span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">font-family</span>: Arial, sans-serif;
}
</code></pre>
<ul>
<li><p><strong>What it does:</strong> It applies the style to <code>h1</code>, <code>h2</code>, and <code>p</code> at the same time.</p>
</li>
<li><p><strong>When to use:</strong> Whenever you find yourself copying and pasting the same styles for different elements. It keeps your code clean and <strong>dry (Don't Repeat Yourself)</strong>.</p>
</li>
</ul>
<h3 id="heading-descendant-selectors"><strong>Descendant Selectors</strong></h3>
<p>Sometimes you want to be very specific based on where an element is sitting.</p>
<p>Imagine you want to style links <code>&lt;a&gt;</code>, but only if they are inside a footer. You don't want to change the other links in your document.</p>
<p>A <strong>Descendant Selector</strong> uses a <strong>space</strong> between two selectors to say Find B that is inside A.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-css"><span class="hljs-selector-tag">footer</span> <span class="hljs-selector-tag">a</span> {
  <span class="hljs-attribute">color</span>: gray;
  <span class="hljs-attribute">text-decoration</span>: none;
}
</code></pre>
<ul>
<li><p><strong>What it does:</strong> It looks(searches) for <code>&lt;footer&gt;</code>, then looks inside it for any <code>&lt;a&gt;</code> tags. It only styles those specific links.</p>
</li>
<li><p><strong>When to use:</strong> When you need context-specific styling without adding new classes to everything.</p>
</li>
</ul>
<h2 id="heading-basic-selector-priority-specificity-algorithm"><strong>Basic Selector Priority (Specificity Algorithm)</strong></h2>
<p>What happens if you have a Paragraph <code>&lt;p&gt;</code> that also has a class <code>.highlight</code>, and you give them different colors? Who wins?</p>
<p>The browser decides using a "Priority" system (technically called <strong>Specificity</strong>). Here is the high-level rule:</p>
<ol>
<li><p><strong>ID Selector</strong> (<code>#id</code>) is the strongest <strong>Specificity</strong>.</p>
</li>
<li><p><strong>Class Selector</strong> (<code>.class</code>) has less <strong>Specificity than ID</strong>.</p>
</li>
<li><p><strong>Element Selector</strong> (<code>p</code>)has the weakest <strong>Specificity</strong>.</p>
</li>
</ol>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Think of<code> important</code> keyword as the <strong>"Trump" card</strong> in a game because it ignores the normal <strong>Specificity </strong>rules that enforce styles using that keyword, because it’s pre-defined (pre-written) in the browser.</div>
</div>

<p>If you say all the paragraphs are Blue (Element selector), but this specific class is Red (Class selector), the Class wins because it is more <strong>specific</strong>.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>CSS Selectors are the control panel of web design. They allow you to target your content with surgical precision.</p>
<ul>
<li><p>Use <strong>Element</strong> selectors for defaults.</p>
</li>
<li><p>Use <strong>Class</strong> selectors for reusable styles (most common).</p>
</li>
<li><p>Use <strong>ID</strong> selectors for unique items.</p>
</li>
<li><p>Use <strong>Group</strong> and <strong>Descendant</strong> selectors to keep your code clean and logical.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[HTML Tags vs. Elements: Clear and Concise Overview]]></title><description><![CDATA[Every website you visit, whether it’s a news site, a social media site, or this blogs built on a fundamental structure. It is created using HTML.
In this blog, we will understand what HTML is, why we use it, what tags and elements are, the difference...]]></description><link>https://devasif-7.hashnode.dev/html-tags-vs-elements-clear-and-concise-overview</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/html-tags-vs-elements-clear-and-concise-overview</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Sat, 31 Jan 2026 11:26:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769855761621/4cb04576-dc95-44f7-b0c8-b70bfa312b43.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every website you visit, whether it’s a news site, a social media site, or this blogs built on a fundamental structure. It is created using <strong>HTML</strong>.</p>
<p>In this blog, we will understand what <strong>HTML</strong> is, why we use it, what <strong>tags</strong> and <strong>elements</strong> are, the difference between <strong>block</strong> and <strong>inline</strong> elements, and look at the most common tags you will use daily.</p>
<p>First, let’s understand what <strong>HTML</strong> is and why it is the foundation of the web.</p>
<h2 id="heading-what-is-html-and-why-do-we-use-it"><strong>What is HTML, and why do we use it</strong></h2>
<p><strong>HTML</strong> stands for <strong>HyperText Markup Language</strong>. It is not a programming language like C or C++; it is a <strong>markup</strong> language. This means it is used to "<strong>mark up</strong>" or label different parts of a document so the computer knows what they are.</p>
<p>We use <strong>HTML</strong> to tell the web browser how to <strong>structure</strong> the content. It tells the browser: This part is a <strong>heading</strong>, This part is a <strong>paragraph</strong>, and This part is an <strong>image</strong>.</p>
<p>Without <strong>HTML</strong>, a browser would just see messy text. <strong>HTML</strong> gives that text <strong>meaning</strong> and <strong>structure</strong>.</p>
<h2 id="heading-what-is-an-html-tag"><strong>What is an HTML tag</strong></h2>
<p>The building blocks of <strong>HTML</strong> are called <strong>tags</strong>. A <strong>tag</strong> is a keyword surrounded by angular brackets (<code>&lt;</code> and <code>&gt;</code>).</p>
<p><strong>Tags</strong> are like <strong>instructions</strong> for the browser. When the browser sees a <strong>tag</strong>, it knows it needs to do something specific with the content inside it. For example, the <code>&lt;b&gt;</code> tag tells the browser to make the text <strong>bold</strong>.</p>
<h2 id="heading-opening-tag-closing-tag-and-content"><strong>Opening tag, closing tag, and content</strong></h2>
<p>Most HTML structures consist of three parts:</p>
<ol>
<li><p><strong>The Opening Tag:</strong> This marks the start of an element (e.g., <code>&lt;p&gt;</code>).</p>
</li>
<li><p><strong>The Content:</strong> The information you want to display (text, images, etc.).</p>
</li>
<li><p><strong>The Closing Tag:</strong> This marks the end of an element. It looks just like the opening tag but includes a <strong>forward slash</strong> (e.g., <code>&lt;/p&gt;</code>).</p>
</li>
</ol>
<p><strong>Example:</strong></p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Hi, I am Asif.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<ul>
<li><p><code>&lt;p&gt;</code> is the <strong>opening tag</strong>.</p>
</li>
<li><p><code>Hi, I am Asif.</code> is the <strong>content</strong>.</p>
</li>
<li><p><code>&lt;/p&gt;</code> is the <strong>closing tag</strong>.</p>
</li>
</ul>
<h2 id="heading-what-an-html-element-means"><strong>What an HTML element means</strong></h2>
<p>Beginners often confuse <strong>tags</strong> and <strong>elements.</strong> Here is the difference:</p>
<ul>
<li><p>A <strong>tag</strong> is just the <code>&lt;...&gt;</code> part.</p>
</li>
<li><p>An <strong>element</strong> is the <strong>entire package</strong>: the opening tag <code>&lt;...&gt;</code> + the content + the closing tag<code>&lt;/…&gt;</code>.</p>
</li>
</ul>
<p>So, when we say <strong>paragraph element,</strong> we mean the whole thing from start to finish.</p>
<h2 id="heading-self-closing-void-elements"><strong>Self-closing (Void) elements</strong></h2>
<p>Most elements follow the rule of <strong>Open</strong>, <strong>Content</strong>, <strong>Close</strong>. However, some elements are <strong>empty</strong>. They do not hold any text or other elements inside them. Because they have no content to wrap, they do not need a closing tag.</p>
<p>These are called <strong>Self-closing</strong> or <strong>Void</strong> elements.</p>
<p><strong>Common Examples:</strong></p>
<ul>
<li><p><code>&lt;br&gt;</code>: Inserts a line break.</p>
</li>
<li><p><code>&lt;img&gt;</code>: Embeds an image.</p>
</li>
<li><p><code>&lt;hr&gt;</code>: Creates a horizontal line.</p>
</li>
</ul>
<p>You just write the tag, and it does its job immediately.</p>
<h2 id="heading-block-level-vs-inline-elements"><strong>Block-level vs Inline Elements</strong></h2>
<p>All the elements do not behave the same way on a page. The two major categories of behavior are <strong>Block-level</strong> and <strong>Inline</strong>.</p>
<h3 id="heading-1-block-level-elements"><strong>1. Block-level Elements</strong></h3>
<p>These elements act like distinct(own) blocks.</p>
<ul>
<li><p>They always start on a new line.</p>
</li>
<li><p>They take up the <strong>full width</strong> available (stretching from left to right).</p>
</li>
<li><p>Examples: <code>&lt;div&gt;</code>, <code>&lt;h1&gt;</code> to <code>&lt;h6&gt;</code>, <code>&lt;p&gt;</code>.</p>
</li>
</ul>
<h3 id="heading-2-inline-elements"><strong>2. Inline Elements</strong></h3>
<p>These elements flow with the text.</p>
<ul>
<li><p>They do not start on a new line.</p>
</li>
<li><p>They only take up as much width as necessary.</p>
</li>
<li><p>Examples: <code>&lt;span&gt;</code>, <code>&lt;a&gt;</code> (anchor/links), <code>&lt;b&gt;</code> (bold).</p>
</li>
</ul>
<h2 id="heading-commonly-used-html-tags"><strong>Commonly used HTML tags</strong></h2>
<p>To get started, you don't need to <strong>memorize</strong> every tag. Let’s build a real <strong>HTML</strong> file together. We will start with the <strong>root</strong> and keep adding tags one by one to see how the structure grows into a full page.</p>
<h3 id="heading-1"><strong>1.</strong> <code>&lt;html&gt;</code></h3>
<p>The root of the <strong>document</strong>. Every <strong>HTML</strong> document starts with this. It tells the browser, Everything inside here is <strong>HTML</strong> code.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h3 id="heading-2"><strong>2.</strong> <code>&lt;head&gt;</code></h3>
<p>This contains <strong>metadata/information</strong> of the document(like the title) that isn't shown on the main page. We place this <strong>inside</strong> the <code>&lt;html&gt;</code> tag.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Tech Blogs | Mohd Asif<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h3 id="heading-3"><strong>3.</strong> <code>&lt;body&gt;</code></h3>
<p>It contains everything <strong>visible</strong> to the user. If you want people to see it, every visible part should be inside the <code>body</code> tag. We place this tag after the <code>&lt;head&gt;</code>, but still inside the <code>&lt;html&gt;</code>.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Tech Blogs | Mohd Asif<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h3 id="heading-4"><strong>4.</strong> <code>&lt;div&gt;</code></h3>
<p>A <strong>generic container tag</strong> used to group elements together. Since we want our content to be organized, let's put a main-container <code>&lt;div&gt;</code> inside the body.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Tech Blogs | Mohd Asif<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"main-container"</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h3 id="heading-5-to"><strong>5.</strong> <code>&lt;h1&gt;</code> to <code>&lt;h6&gt;</code></h3>
<p><strong>Headings</strong> are used to title your content. Let's add a main heading inside our <code>&lt;div&gt;</code>.</p>
<p><code>&lt;h1&gt;…&lt;/h1&gt;</code> is the <strong>primary</strong> heading.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Tip: We should use <code>&lt;h1&gt;…&lt;/h1&gt;</code> only once in the web page for better <strong>SEO</strong>.</div>
</div>

<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Tech Blogs | Mohd Asif<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"main-container"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome to My Tech Blogs<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h3 id="heading-6"><strong>6.</strong> <code>&lt;p&gt;</code></h3>
<p><strong>Paragraphs</strong> are for normal text. Let's add a description under our heading.</p>
<pre><code class="lang-xml">/<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Tech Blogs | Mohd Asif<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"main-container"</span>&gt;</span>
       <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome to My Tech Blogs<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Learning software development.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h3 id="heading-7"><strong>7.</strong> <code>&lt;span&gt;</code></h3>
<p>This is used to add or <strong>style</strong> small parts of text without breaking the line (inline). Let's use it to highlight the word <strong>(usually)</strong> in our paragraph.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Tech Blogs | Mohd Asif<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"main-container"</span>&gt;</span>
       <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome to My Tech Blogs<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Learning <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"color: #fb923c;"</span>&gt;</span>software development<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h3 id="heading-8"><strong>8.</strong> <code>&lt;a&gt;</code></h3>
<p>The <strong>Anchor</strong> tag creates links. Let's add a link to the portfolio at the end of the content.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Tech Blogs | Mohd Asif<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"text-align: center;"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"main-container"</span>&gt;</span>
       <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome folks to My Tech Blogs<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Learning <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"color: #fb923c;"</span>&gt;</span>software development<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://devasif-7.hashnode.dev/"</span>&gt;</span>Check out Mohd Asif's blogs.<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>Now we have completed an <strong>HTML</strong> file! You can copy the final code, save it as <code>index.html</code>, and open it in your browser to see the result.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769858525335/c4cac183-611f-4582-b672-d3cd029a322e.jpeg" alt class="image--center mx-auto" /></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>We have different tags for different works, but we do not need to memorize all the tags. As we work and write more code, we will learn them all eventually.</strong></div>
</div>

<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p><strong>HTML</strong> creates the <strong>skeleton</strong> of the web page. It uses <strong>tags</strong> to define elements. Understanding these basic <strong>tags</strong>, <strong>elements</strong>, and their behaviors is the very first step to becoming a <strong>web developer</strong>. Once you understand <strong>HTML</strong> clearly, learning <strong>CSS</strong> and <strong>JavaScript</strong> becomes much easier.</p>
]]></content:encoded></item><item><title><![CDATA[Emmet for HTML]]></title><description><![CDATA[Writing HTML is the foundation of web development, but let's be honest, typing out all those opening and closing tags < > again and again can get tiring. It feels repetitive and slows you down.
What if there was a way to type a short code like ul>li*...]]></description><link>https://devasif-7.hashnode.dev/emmet-for-html</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/emmet-for-html</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Fri, 30 Jan 2026 21:54:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769808960064/faa57fbb-0ab9-46ff-9d85-285e8459ece8.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Writing <strong>HTML</strong> is the foundation of <strong>web development,</strong> but let's be honest, typing out all those opening and closing tags <code>&lt; &gt;</code> again and again can get <strong>tiring</strong>. It feels repetitive and slows you down.</p>
<p>What if there was a way to type a short code like <code>ul&gt;li*3</code> and have it magically turn into a full list? That is exactly what <strong>Emmet</strong> does.</p>
<p>In this blog, we will understand what <strong>Emmet</strong> is, why it is a lifesaver for beginners, how it works in your editor, and master the basic syntax to <strong>create</strong> elements, a<strong>dd classes</strong>, <strong>nest items</strong>, and generate full HTML structures instantly.</p>
<h2 id="heading-what-is-emmet"><strong>What is Emmet</strong></h2>
<p><strong>Emmet</strong> is a plugin for text editors that acts like <strong>autocorrect</strong> or <strong>shorthand</strong> for <strong>HTML</strong> code. Just like you might type <strong>omg</strong> and your phone changes it to <strong>Oh my god</strong>, <strong>Emmet</strong> lets you type simple <strong>abbreviations</strong>(the short code) and <strong>expands</strong> them into <strong>full</strong> blocks of HTML code.</p>
<p>It is built in and can be plugged into popular editors like <strong>VS Code,</strong> so you don't even need to install it separately.</p>
<h3 id="heading-why-emmet-is-useful-for-html-beginners"><strong>Why Emmet is useful for HTML beginners</strong></h3>
<p>As a beginner, you might think you should type everything manually to learn better. While that is true for the first few days, typing every single bracket quickly becomes a waste of time.</p>
<ul>
<li><p><strong>Speed:</strong> You can write 100 lines of code in seconds.</p>
</li>
<li><p><strong>Fewer Errors:</strong> Emmet always creates the opening and closing tags together, so you never forget to close a <code>&lt;/div&gt;</code>.</p>
</li>
<li><p><strong>Clean Code:</strong> It automatically formats your indentation properly.</p>
</li>
</ul>
<h3 id="heading-how-emmet-works-inside-code-editors"><strong>How Emmet works inside code editors</strong></h3>
<p>The workflow is so simple:</p>
<ol>
<li><p><strong>Type the abbreviation</strong> (the short code).</p>
</li>
<li><p><strong>Press a trigger key</strong> (usually <code>Tab</code> or <code>Enter</code>).</p>
</li>
<li><p><strong>Watch it expand</strong> into full HTML.</p>
</li>
</ol>
<p>For example, if you are in VS Code, you simply type <code>h1</code> and press <code>Tab</code>.</p>
<p><strong>Result:</strong> <code>&lt;h1&gt;&lt;/h1&gt;</code></p>
<p>Now, let's look at the specific syntax you will use every day.</p>
<h2 id="heading-creating-html-elements-using-emmet"><strong>Creating HTML elements using Emmet</strong></h2>
<p>The most basic usage is just typing the tag name. You don't need to type the angle brackets <code>&lt;</code> or <code>&gt;</code>.</p>
<ul>
<li><p>Input: <code>p</code> + <code>Tab</code></p>
</li>
<li><p>Output: <code>&lt;p&gt;&lt;/p&gt;</code></p>
</li>
<li><p>Input: <code>button</code> + <code>Tab</code></p>
</li>
<li><p>Output: <code>&lt;button&gt;&lt;/button&gt;</code></p>
</li>
</ul>
<h3 id="heading-adding-classes-ids-and-attributes"><strong>Adding classes, IDs, and attributes</strong></h3>
<p>In <strong>CSS</strong> and <strong>JS</strong>, we use <code>.</code> for classes and <code>#</code> for IDs. Emmet uses the same logic.</p>
<p><strong>Adding a Class:</strong></p>
<ul>
<li><p>Input: <code>div.container</code></p>
</li>
<li><p>Output:</p>
</li>
<li><pre><code class="lang-xml">  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
</li>
</ul>
<p><strong>Adding an ID:</strong></p>
<ul>
<li><p>Input: <code>div#main</code></p>
</li>
<li><p>Output:</p>
</li>
<li><pre><code class="lang-xml">  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"main"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
</li>
</ul>
<p><strong>Combining both:</strong></p>
<ul>
<li><p>Input: <code>div#header.nav-bar</code></p>
</li>
<li><p>Output:</p>
</li>
<li><pre><code class="lang-xml">  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"header"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"nav-bar"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
</li>
</ul>
<p><strong>Adding Attributes:</strong></p>
<p>If you need specific attributes, use square brackets <code>[]</code>.</p>
<ul>
<li><p>Input: <code>a[href="</code><a target="_blank" href="http://google.com/"><code>google.com</code></a><code>"]</code></p>
</li>
<li><p>Output:</p>
</li>
<li><pre><code class="lang-xml">    <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"google.com"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</code></pre>
</li>
</ul>
<h3 id="heading-creating-nested-elements-children-and-siblings"><strong>Creating nested elements (Children and Siblings)</strong></h3>
<p>HTML is a tree structure where elements are inside other elements. Emmet lets you build this hierarchy using <code>&gt;</code> (child) and <code>+</code> (sibling).</p>
<p><strong>The Child Operator (</strong><code>&gt;</code>)</p>
<p>Use this when you want to put one element inside another.</p>
<ul>
<li><p>Input: <code>div&gt;p</code></p>
</li>
<li><p>Output:</p>
</li>
</ul>
<pre><code class="lang-xml"> <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p><strong>The Sibling Operator (</strong><code>+</code>)</p>
<p>Use this when you want elements to be on the same level, next to each other.</p>
<ul>
<li><p>Input: <code>h1+p</code></p>
</li>
<li><p>Output:</p>
</li>
</ul>
<pre><code class="lang-xml"> <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<h3 id="heading-repeating-elements-using-multiplication"><strong>Repeating elements using multiplication</strong></h3>
<p>This is one of the most powerful features. Instead of copy-pasting a line 5 times, just multiply it using <code>*</code>.</p>
<ul>
<li><p>Input: <code>li*3</code></p>
</li>
<li><p>Output:</p>
</li>
</ul>
<pre><code class="lang-xml">  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
</code></pre>
<p><strong>Combining Nesting and Multiplication:</strong></p>
<p>You can mix these to create complex lists in one go.</p>
<ul>
<li><p>Input: <code>ul&gt;li*3</code></p>
</li>
<li><p>Output:</p>
</li>
</ul>
<pre><code class="lang-xml"> <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<h3 id="heading-generating-full-html-boilerplate-with-emmet"><strong>Generating full HTML boilerplate with Emmet</strong></h3>
<p>When you start a new file, you usually need the standard HTML structure (<code>&lt;html&gt;</code>, <code>&lt;head&gt;</code>, <code>&lt;body&gt;</code>). Typing this from memory is hard.</p>
<p>Emmet makes this instant.</p>
<ul>
<li><p>Input: <code>!</code> + <code>Tab</code></p>
</li>
<li><p>Output:</p>
</li>
</ul>
<pre><code class="lang-xml">  <span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Document<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>

  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h3 id="heading-emmet-cheat-sheet"><strong>Emmet Cheat Sheet</strong></h3>
<p>Here is your quick-reference cheat sheet for Emmet. You can save this or pin it while you are coding to speed up your workflow!</p>
<table><tbody><tr><td><p><strong>Feature</strong></p></td><td><p><strong>What you Type</strong></p></td><td><p><strong>What you Get (Result)</strong></p></td></tr><tr><td><p><strong>Basic Tag</strong></p></td><td><p><code>h1</code></p></td><td><p><code>&lt;h1&gt;&lt;/h1&gt;</code></p></td></tr><tr><td><p><strong>Class</strong></p></td><td><p><code>.box</code></p></td><td><p><code>&lt;div class="box"&gt;&lt;/div&gt;</code></p></td></tr><tr><td><p><strong>ID</strong></p></td><td><p><code>#header</code></p></td><td><p><code>&lt;div id="header"&gt;&lt;/div&gt;</code></p></td></tr><tr><td><p><strong>Tag + Class</strong></p></td><td><p><code>p.text</code></p></td><td><p><code>&lt;p class="text"&gt;&lt;/p&gt;</code></p></td></tr><tr><td><p><strong>Child (Nest)</strong></p></td><td><p><code>ul&gt;li</code></p></td><td><p><code>&lt;ul&gt;&lt;li&gt;&lt;/li&gt;&lt;/ul&gt;</code></p></td></tr><tr><td><p><strong>Sibling (Next to)</strong></p></td><td><p><code>h1+p</code></p></td><td><p><code>&lt;h1&gt;&lt;/h1&gt;&lt;p&gt;&lt;/p&gt;</code></p></td></tr><tr><td><p><strong>Multiplication</strong></p></td><td><p><code>li<em>3</em></code></p></td><td><p><code>&lt;li&gt;&lt;/li&gt;&lt;li&gt;&lt;/li&gt;&lt;li&gt;&lt;/li&gt;</code></p></td></tr><tr><td><p><strong>Attributes</strong></p></td><td><p><code>img[src="logo.png"]</code></p></td><td><p><code>&lt;img src="logo.png" alt=""&gt;</code></p></td></tr><tr><td><p><strong>Complex Combo</strong></p></td><td><p><code>ul&gt;li.item3</code></p></td><td><p><code>&lt;ul&gt;&lt;li class="item"&gt;&lt;/li&gt;...&lt;/ul&gt;</code> (3 times)</p></td></tr><tr><td><p></p></td><td><p></p></td><td><p></p></td></tr></tbody></table>

<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p><strong>Emmet</strong> transforms the way you write <strong>HTML</strong>. It changes coding from a typing test into a logic structure exercise. By using simple abbreviations(the short code), you can generate complex layouts instantly without worrying about missing a closing tag or a quote.</p>
<p>Mastering these few shortcuts will make you significantly faster and more confident in your web development journey.</p>
]]></content:encoded></item><item><title><![CDATA[TCP Working: 3-Way Handshake & Reliable Communication]]></title><description><![CDATA[Right now, millions of data packets are moving/transmitting across the internet every second. If we send this data without any rules/protocols, it will turn into a mess, packets will get lost, arrive in the wrong order, or get broken. To stop this fr...]]></description><link>https://devasif-7.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Fri, 30 Jan 2026 21:26:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769806457166/6293175e-8b51-4f23-90a1-c3395bca484a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Right now, millions of data packets are moving/transmitting across the internet every second. If we send this data without any rules/protocols, it will turn into a mess, packets will get lost, arrive in the wrong order, or get broken. To stop this from happening, we need <strong>protocols</strong>. These are just rules that make sure data gets from point A to point B safely and correctly.</p>
<p>In this blog, we will understand what <strong>TCP is</strong>, why it is needed, what problems it solves, how the <strong>TCP 3-Way Handshake</strong> works, how data is transferred, how reliability is maintained, and how a <strong>TCP</strong> connection is closed.</p>
<h2 id="heading-what-is-tcp-and-why-is-it-needed"><strong>What is TCP, and why is it needed</strong></h2>
<p><strong>TCP (Transmission Control Protocol)</strong> is one of the most important protocols used on the Internet. It is designed to send data safely from one computer system to another. Without <strong>TCP</strong>, data can be <strong>lost</strong>, <strong>duplicated</strong>, or mixed in the <strong>wrong order</strong>.</p>
<p><strong>TCP</strong> is needed because the Internet is not perfect. Networks can be <strong>slow</strong>, <strong>unstable</strong>, or <strong>overloaded</strong>. <strong>TCP</strong> makes sure that data reaches the correct destination, in the correct order, and without errors. That is why <strong>TCP</strong> is mainly used where accuracy and reliability are very important.</p>
<h2 id="heading-problems-tcp-is-designed-to-solve"><strong>Problems TCP is designed to solve</strong></h2>
<p>When data is sent without rules, many problems can happen.</p>
<ul>
<li><p>Sometimes packets are lost on the way.</p>
</li>
<li><p>Sometimes packets may arrive in the wrong order.</p>
</li>
<li><p>Sometimes the same packet may be received twice.</p>
</li>
<li><p>Sometimes data may be corrupted during transfer.</p>
</li>
</ul>
<p><strong>TCP</strong> is designed to solve all these problems. It checks every packet, keeps track of the order, resends lost data, and confirms successful delivery.</p>
<h2 id="heading-what-is-the-tcp-3-way-handshake"><strong>What is the TCP 3-Way Handshake?</strong></h2>
<p>Before sending any real data, <strong>TCP</strong> first creates a proper connection between the <strong>client</strong> and the <strong>server</strong>. This process is called <strong>the 3-Way Handshake</strong>.</p>
<p>It is used to make sure that both sides are ready to communicate and agree on starting the data transfer.</p>
<p>You can think of it like a simple conversation before starting to talk.</p>
<p><strong>Client:</strong> Can I talk to you?<br /><strong>Server:</strong> Yes, I am ready.<br /><strong>Client:</strong> Okay, let’s start.</p>
<p>After this, the real communication begins.</p>
<h2 id="heading-step-by-step-working-of-syn-syn-ack-and-ack"><strong>Step-by-step working of SYN, SYN-ACK, and ACK</strong></h2>
<p>These are just buzzwords; let’s understand them.</p>
<p><strong>First Step – SYN (short term for Synchronize)</strong><br />The <strong>client</strong> sends a message called <strong>SYN</strong> to the server.<br />This means: I want to start a connection.</p>
<p><strong>Second Step – SYN-ACK</strong><br />The <strong>server</strong> replies with <strong>SYN-ACK</strong>.<br />This means: I received your request and I am ready to connect.</p>
<p><strong>Third Step – ACK (short term for Acknowledgement)</strong><br />The <strong>client</strong> sends back ACK.<br />This means: Connection confirmed, let’s start sending data.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">After these three steps, a secure TCP connection is created.</div>
</div>

<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769807995146/d93e772b-0b79-4a6c-bfcb-33c80b4a7a02.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-how-tcp-ensures-reliability-order-and-correctness"><strong>How TCP ensures reliability, order, and correctness</strong></h2>
<ul>
<li><p><strong>TCP</strong> ensures reliability by confirming every packet using acknowledgements.</p>
</li>
<li><p><strong>TCP</strong> ensures order by using sequence numbers and arranging packets properly.</p>
</li>
<li><p><strong>TCP</strong> ensures correctness by checking errors and retransmitting lost packets.</p>
</li>
</ul>
<p>If the network is slow or unstable, <strong>TCP</strong> automatically adjusts the speed and resends missing data. This makes communication stable and safe.</p>
<h2 id="heading-how-a-tcp-connection-is-closed"><strong>How a TCP connection is closed</strong></h2>
<p>When data transfer is completed, the connection must be closed properly. <strong>TCP</strong> closes the connection using <strong>FIN(Finish)</strong> and <strong>ACK(Acknowledgement)</strong> messages.</p>
<ul>
<li><p>First, one side sends <strong>FIN</strong>, meaning: I am done <strong>sending</strong> data.</p>
</li>
<li><p>The other side replies with <strong>ACK</strong>, meaning: I <strong>received</strong> your message.</p>
</li>
<li><p>Then the second side sends its own <strong>FIN</strong>.</p>
</li>
<li><p>Finally, the first side replies with <strong>ACK</strong>, and the connection is <strong>closed</strong>.</p>
</li>
</ul>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">This clean closing makes sure that no data is left unfinished.</div>
</div>

<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p><strong>TCP</strong> is a powerful and reliable protocol that makes the Internet work smoothly. It creates <strong>safe</strong> connections, sends data in the <strong>correct</strong> order, handles <strong>errors</strong>, and <strong>closes</strong> connections properly. Without <strong>TCP</strong>, web browsing, file downloading, and email would be unreliable and messy.</p>
<p>Understanding <strong>TCP</strong> helps you see how data travels safely behind the scenes every time you open a website or send a file.</p>
]]></content:encoded></item><item><title><![CDATA[TCP vs UDP: When to Use What, and How TCP Relates to HTTP]]></title><description><![CDATA[How the data is sent/transmitted over a network, there were no protocols/rules in the past to send the data from one computer to another. To solve this problem, some protocols/rules were standardized for how the data will be sent over the internet.
T...]]></description><link>https://devasif-7.hashnode.dev/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Fri, 30 Jan 2026 20:43:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769794870714/fdde1a37-997e-4b82-aa6e-12032be58244.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>How the data is sent/transmitted over a network, there were no <strong>protocols/rules in the past</strong> to send the data from one computer to another. To solve this problem, some protocols/rules were standardized for how the data will be sent over the internet.</p>
<p><strong>TCP</strong> and <strong>UDP</strong> are the most widely used data-sharing protocols on the Internet. These are widely used to share data from one computer system to another.</p>
<p>In this article, we will understand the difference between TCP and UDP, how HTTP is related to TCP, and how <strong>HTTP</strong> works.</p>
<p>Firstly, we find out what <strong>TCP</strong> and <strong>UDP</strong> are.</p>
<h2 id="heading-tcp-transmission-control-protocol"><strong>TCP (Transmission Control Protocol)</strong></h2>
<p><strong>TCP</strong> is the most common and reliable protocol for data sharing on internet. It ensures the safety of the data, makes the proper connection to the receiver before sending any data, and guarantees that every packet of data will reach the receiver device successfully.</p>
<p><strong>TCP</strong> uses three way handshake to ensure the safety of the data. First, the client sends a request, then the server makes a secure and reliable connection to the client, and then the server sends data to the client.</p>
<h3 id="heading-when-to-use">When to use</h3>
<p>Most of the time, users use <strong>TCP</strong> when they need reliability, security, etc, of the data. <strong>TCP</strong> ensures 100% accuracy and proper error handling, mainly used in browser file sharing.</p>
<h2 id="heading-udp-user-datagram-protocol"><strong>UDP (User Datagram Protocol)</strong></h2>
<p>This is the faster version of TCP. It doesn’t care about anything, data packet loss, or security. It is just want to know the address of the client and start sending the data. In this, if the internet is slow, we have a loss of data and a connection break, which is an unreliable way of transferring data.</p>
<h3 id="heading-when-to-use-1"><strong>When to use</strong></h3>
<p>When we need to send the data fast, the quality of the data is not that important; we can compromise with that. If some data packets are lost, it doesn’t affect too much. Mainly used in voice and video calls, live transmission/broadcasting, and online gaming.</p>
<h2 id="heading-key-differences-between-tcp-and-udp"><strong>Key differences between TCP and UDP</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769805186885/df0c60cc-5381-4174-9b1b-219990f146fd.jpeg" alt class="image--center mx-auto" /></p>
<p><strong>Reliability:</strong><br />TCP is reliable. Every packet of data moves/transmits safely at the client. <strong>UDP</strong> is less reliable. Some data packets can be lost during transmission.</p>
<p><strong>Speed:</strong><br /><strong>TCP</strong> is slower because it checks every packet, confirms delivery, and handles errors. <strong>UDP</strong> is faster because it simply sends data without checking anything.</p>
<p><strong>Connection:</strong><br /><strong>TCP</strong> needs a 3-way handshake before starting communication, so a proper connection is created first. <strong>UDP</strong> does not need any handshake and starts sending data immediately.</p>
<p><strong>Order:</strong><br />In <strong>TCP</strong>, data always moves/transmits in the correct order. In <strong>UDP</strong>, data can arrive in any order and may not be arranged properly.</p>
<p><strong>Best Used For:</strong><br /><strong>TCP</strong> is mainly used for web browsing, email, and file sharing, where accuracy is important. <strong>UDP</strong> is mainly used for video calls, live streaming, and gaming, where speed is more important than perfect accuracy.</p>
<h2 id="heading-how-http-is-related-to-tcp"><strong>How HTTP is related to TCP</strong></h2>
<p><strong>HTTP (HyperText Transfer Protocol)</strong> is used by browsers and servers to talk to each other and exchange website data. But <strong>HTTP</strong> itself cannot send data directly on the network. For sending data safely from one computer to another, <strong>HTTP</strong> mostly depends on <strong>TCP</strong>. HTTP is a subset of TCP.</p>
<p>When you open any website, first, a <strong>TCP</strong> connection is created between your browser and the server using the <strong>3-way handshake</strong>. After this secure connection is ready<strong>, HTTP</strong> sends its requests and receives responses through this <strong>TCP</strong> connection. Because <strong>TCP</strong> is reliable, <strong>HTTP</strong> can be sure that the web pages, images, and data reach correctly and in proper order.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769805584103/6a3a4d52-25de-4fe9-a2d0-4a291e274410.webp" alt class="image--center mx-auto" /></p>
<p>So, <strong>HTTP</strong> works on top of <strong>TCP</strong>. <strong>TCP</strong> handles <strong>connection</strong>, <strong>safety</strong>, <strong>order</strong>, and <strong>error checking</strong>, and HTTP only focus on what data to send and how to format it. That is why web browsing is stable and reliable in most cases.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769805699428/c8be34e2-f65e-4d7f-ae77-a796d81ac5fb.jpeg" alt class="image--center mx-auto" /></p>
<p>Choosing between <strong>TCP</strong> and <strong>UDP</strong> depends on what you need. If you want safety and 100% accuracy, go with <strong>TCP</strong>. If you want raw speed and can handle some data loss, <strong>UDP</strong> is your friend. Understanding these helps you see how the "invisible" parts of the internet work every time you click a link!</p>
]]></content:encoded></item><item><title><![CDATA[What is cURL?]]></title><description><![CDATA[What is a server
A server is nothing but anything that serves something. In computer science, a server is a computer/software that provides information to other computers (clients). It receives requests, processes them, and sends back responses.
Serv...]]></description><link>https://devasif-7.hashnode.dev/what-is-curl</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/what-is-curl</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Thu, 29 Jan 2026 21:19:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769714474817/6431cf2a-8e3c-4711-83b3-d27477f33798.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-a-server">What is a server</h2>
<p>A <strong>server</strong> is nothing but anything that serves something. In computer science, a server is a <strong>computer/software</strong> that provides information to other computers <strong>(clients).</strong> It receives requests, processes them, and sends back responses.</p>
<p>Servers usually perform tasks such as:</p>
<ul>
<li><p>Storing and retrieving data</p>
</li>
<li><p>Running application logic</p>
</li>
<li><p>Connecting to databases</p>
</li>
<li><p>Sending responses over the internet</p>
</li>
</ul>
<p>For example, when a user opens a website in the browser, the browser <strong>sends</strong> a request to a <strong>web server</strong>. The server processes the request and sends back the webpage content, which the browser then renders.</p>
<h2 id="heading-why-do-clients-need-to-talk-to-servers"><strong>Why Do Clients Need to Talk to Servers?</strong></h2>
<p>These days, most applications do not work in isolation. These applications depend on performing these key tasks, such as <strong>authentication</strong>, <strong>authorization</strong>, <strong>data storage</strong>, and <strong>business logic.</strong></p>
<p>Client needs to talk to the servers because:</p>
<ul>
<li><p>Fetch users’ data, like user profiles or product lists</p>
</li>
<li><p>Send data like login details or form submissions</p>
</li>
<li><p>Update or delete existing information</p>
</li>
</ul>
<p>This communication system follows a <strong>request–response</strong> model. The client always initiates the request, and the server always sends back a response.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769717827280/6ae77b44-532d-4f1b-939e-d982bfdebd22.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-curl"><strong>What is cURL</strong></h2>
<p>cURL is a command-line tool (a utility) that allows users to send a request to a server and receive responses directly in the <strong>terminal</strong>.</p>
<p>In a simple way to send <strong>messages (queries)</strong> to a server without using any <strong>application.</strong> Typing the <strong>cURL</strong> command, it sends the request to the server, and the server’s response is printed on the terminal window.</p>
<p>cURL is widely used because it is:</p>
<ul>
<li><p>Simple and lightweight</p>
</li>
<li><p>Available on most operating systems</p>
</li>
<li><p>Extremely useful for testing and debugging</p>
</li>
</ul>
<h2 id="heading-why-programmers-need-curl"><strong>Why Programmers Need cURL</strong></h2>
<p>For programmers, <strong>cURL</strong> is more than just a tool. It is a teacher. It helps you understand exactly how the internet works by showing you the raw conversation between computers.</p>
<p>Using cURL helps programmers:</p>
<ul>
<li><p>Understand how HTTP communication works</p>
</li>
<li><p>Test APIs without building a frontend</p>
</li>
<li><p>Debug server-side issues quickly</p>
</li>
<li><p>Gain confidence working with backend systems</p>
</li>
</ul>
<p>Many beginners struggle with APIs because they never see what is actually being sent or received. cURL removes that confusion by showing everything clearly in the terminal.</p>
<h2 id="heading-making-your-first-request-using-curl"><strong>Making Your First Request Using cURL</strong></h2>
<p>The simplest thing you can do with cURL is fetch a webpage.</p>
<p>For example, when you run the following command:</p>
<pre><code class="lang-bash">curl https://devasif-7.hashnode.dev
</code></pre>
<p>cURL sends a request to the server at <a target="_blank" href="http://devasif-7.hashnode.dev"><strong>devasif-7.hashnode.dev</strong></a>. The server processes the request and sends back a response containing the webpage’s HTML. cURL then prints that response directly in the terminal.</p>
<p>This single command demonstrates the core idea behind cURL: sending a request and receiving a response.</p>
<h2 id="heading-understanding-request-and-response"><strong>Understanding Request and Response</strong></h2>
<p>Every interaction using cURL follows the same pattern: a request is sent, and a response is received.</p>
<p>A <strong>request</strong> usually includes:</p>
<ul>
<li><p>The server address (URL)</p>
</li>
<li><p>The type of action to perform</p>
</li>
</ul>
<p>A <strong>response</strong> usually includes:</p>
<ul>
<li><p>A status code indicating success or failure</p>
</li>
<li><p>Data returned by the server</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769720699265/ed67dc8f-a4bc-4756-9cf4-9106b4222363.png" alt class="image--center mx-auto" /></p>
<p>For example, a status code of <strong>200</strong> means the request was <strong>successful</strong>, while <strong>404</strong> means the requested resource was <strong>not found</strong>. Understanding these responses is key to debugging and learning how servers behave.</p>
<h2 id="heading-get-and-post-requests"><strong>GET and POST Requests</strong></h2>
<p>HTTP defines different types of requests, but beginners only need to focus on mainly two: GET and POST.</p>
<p>A <strong>GET request</strong> is used to request data from a server. When you fetch a webpage or retrieve user data, you are usually making a GET request.</p>
<p>A <strong>POST request</strong> is used to send data to a server. This is commonly used for actions like logging in, signing up, or submitting forms.</p>
<p>cURL supports both of these request types and allows you to experiment with them directly from the terminal.</p>
<h2 id="heading-using-curl-to-talk-to-apis"><strong>Using cURL to Talk to APIs</strong></h2>
<p>APIs are <strong>codes/servers</strong> that are designed to return data instead of web pages. They often return data in formats like JSON.</p>
<p>When you use <strong>cURL</strong> to call an <strong>API</strong>, the process is the same:</p>
<ul>
<li><p>cURL sends a request</p>
</li>
<li><p>The API processes it</p>
</li>
<li><p>The response is returned in the terminal</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769721731041/0bdc7f65-0fa9-4aa3-9b2e-146d1fa94fee.jpeg" alt class="image--center mx-auto" /></p>
<p>This is how mobile apps, web apps, and backend services communicate with each other. cURL allows you to experience this communication firsthand.</p>
<h2 id="heading-common-mistakes-beginners-make-with-curl"><strong>Common Mistakes Beginners Make with cURL</strong></h2>
<p>Beginners often try to learn <strong>cURL</strong> by memorizing many command options at once. This can be confusing and discouraging.</p>
<p>Other common mistakes include:</p>
<ul>
<li><p>Ignoring the response and focusing only on the command</p>
</li>
<li><p>Not understanding status codes</p>
</li>
<li><p>Assuming cURL is only for advanced users</p>
</li>
</ul>
<p>The best approach is to start simple, understand the basics, and gradually explore more features.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p><strong>cURL</strong> is a powerful yet beginner-friendly tool that helps developers understand how clients and servers communicate. By using cURL, you gain a clearer picture of how requests are sent, how servers respond, and how APIs work internally.</p>
]]></content:encoded></item><item><title><![CDATA[The Basics of DNS Records: What They Do and How They Work]]></title><description><![CDATA[As we know, the browser knows where the website lives. It’s because of DNS. If you need to send something to your friend by computer. The DNS finds the computer, and when you send something, it goes to the right device because of the DNS.
In this art...]]></description><link>https://devasif-7.hashnode.dev/the-basics-of-dns-records-what-they-do-and-how-they-work</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/the-basics-of-dns-records-what-they-do-and-how-they-work</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Wed, 28 Jan 2026 20:55:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769627878182/6a1134be-6eee-4490-8723-3b33af419dd3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As we know, the browser knows where the website lives. It’s because of DNS. If you need to send something to your friend by computer. The DNS finds the computer, and when you send something, it goes to the right device because of the DNS.</p>
<p>In this article, we will discuss what the different DNS records are and why we use them.</p>
<h2 id="heading-the-a-record">The A Record</h2>
<p>This is the most commonly used record. This maps your IP address to a domain name so the other users can search it through Internet. It works on the <strong>IPv4 address</strong>.</p>
<h3 id="heading-how-does-it-work">How does it work</h3>
<p>When you type <a target="_blank" href="http://google.com">google.com</a>, the <strong>DNS resolver</strong> finds the <strong>A record</strong> and immediately returns the IP.</p>
<p>(Ex-<strong>199.9.9.0</strong>). Now your browser knows the exact IP address of the server.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769629736571/dcc862ca-288a-4176-a5d9-6903879b1074.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-cname-record"><strong>The CNAME Record</strong></h2>
<p>This is the most common record used by beginners when you host your website on 3rd party providers (domain providers) like <strong>Vercel</strong> or Netlify. This adds an extra layer of <strong>domain</strong> before <strong>mapping to the IP</strong>. The 3rd party providers give you a domain, and if you want to add your domain to that website, you need to map your domain to their domain, and then the browser gets the real IP to connect to the server.</p>
<p>This is also used by big companies like Google and Apple to map their other domain to their real domain.]</p>
<h3 id="heading-how-does-it-work-1">How does it work</h3>
<p>If you have a CNAME for <strong>blog.example.com</strong> pointing to <strong>vercel.app</strong> the resolver first finds the CNAME, sees it’s an <strong>alias</strong>, and then has to perform a second lookup to find the A record of the target.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769631517809/f0b85c4b-9967-4b23-af8c-e64c956f0fd5.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-mx-record"><strong>The MX Record</strong></h2>
<p>This record is useful for receiving or sending <strong>emails</strong> from your domain. Most of the users use their email at <mark>yourname@gmail.com</mark> for their emails, but companies use an email with their domain address, like <a target="_blank" href="http://google.com">google.com</a> or Xyz. in.</p>
<h3 id="heading-how-does-it-work-2">How does it work</h3>
<p>When someone sends an email to <mark>you@example.com</mark>, their mail server asks DNS, "Where should I deliver this?" The DNS responds with a list of <strong>Mail Exchangers</strong> (such as <mark>aspmx.l.google.com</mark>). The sender then establishes an <strong>SMTP connection</strong> with that server to drop off the message.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769631862020/fe8a0b6e-edec-4199-aa7c-2bc69fd86ab0.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-ns-record"><strong>The NS Record</strong></h2>
<p>This record is used to identify who is responsible for answering your query. Let's suppose you buy a domain from <strong>Hostinger</strong>. So by default, they add an NS record to your domain, so they are responsible for answering all the queries.</p>
<h3 id="heading-how-does-it-work-3">How does it work</h3>
<p>When a browser looks for <mark>example.com</mark>, it first asks the "Root" and "TLD" servers (like the <mark>.com</mark> registry ). Those servers look at your <strong>NS records</strong> and say, We don't know the IP, but <strong>GoDaddy</strong> or <strong>Hostinger</strong> does, go ask them!</p>
<p><strong>This is acting like a boss record.</strong> Without valid NS records, the rest of your records (<strong>A, CNAME, MX)</strong> are invisible because no one knows who to ask for them.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769633430278/8822e4e5-39db-4af3-bcdf-89d761f6fbd5.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-aaaa-record"><strong>The AAAA Record</strong></h2>
<p>As technologies grow rapidly, we need a new record for storing new IP that follows the (128-bit system). It is the upgraded version of an <strong>A record</strong> that works the same, but is used for storing new big IPs. While the <strong>A record</strong> uses <strong>IPv4</strong> (the older, 32-bit address system), the <strong>AAAA Record</strong> (pronounced "Quad-A") maps a domain name to an <strong>IPv6 address</strong>.</p>
<h3 id="heading-how-does-it-work-4">How does it work</h3>
<p>It works exactly like an A record. When a device that supports IPv6 (like most modern smartphones and computers) looks up your site, it will look for the AAAA record first. If it finds a 128-bit address (e.g., <code>2001:0db8:85a3:0000:0000:8a2e:0370:7334</code>), it connects via the newer, faster protocol.</p>
<h2 id="heading-putting-it-together"><strong>Putting it Together</strong></h2>
<p>Think of your DNS settings like a company directory:</p>
<ul>
<li><p><strong>NS:</strong> The Receptionist (tells you which department to talk to).</p>
</li>
<li><p><strong>A/AAAA/CNAME:</strong> The Department Address (leads you to the website).</p>
</li>
<li><p><strong>MX:</strong> The Mailroom (handles all incoming mail).</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How DNS Resolution Works]]></title><description><![CDATA[When you open any website, you type a name like google.com or amazon.com. These names are used for humans because remembering them is easy. But computers cannot understand these names. They only understand numbers called IP addresses. So, there is a ...]]></description><link>https://devasif-7.hashnode.dev/how-dns-resolution-works</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/how-dns-resolution-works</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[dns]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Wed, 28 Jan 2026 19:03:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769620772467/e5e8562d-f48d-4f66-9117-4dec01792406.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When you open any website, you type a name like <a target="_blank" href="http://google.com">google.com</a> or <a target="_blank" href="http://amazon.com">amazon.com</a>. These names are used for humans because remembering them is easy. But computers cannot understand these names. They only understand numbers called IP addresses. So, there is a system called <strong>DNS</strong> that acts as a translator, mapping names to IP addresses and vice versa, so your computer knows which server to connect to.</p>
<p>In this blog, we will understand what DNS is and why name resolution exists, what the <strong>dig</strong> command is, how DNS resolution happens step by step using <strong>root, TLD,</strong> and <strong>authoritative name servers</strong>, and how this connects to real browser requests.</p>
<h2 id="heading-what-is-dns-and-why-does-name-resolution-exist"><strong>What is DNS, and why does name resolution exist?</strong></h2>
<p>DNS (Domain Name System) is like the phonebook of the Internet(typical definition). Humans like to remember names such as <a target="_blank" href="http://google.com">google.com</a>, but computers understand numbers such as 199.9.9.0.</p>
<p>DNS converts domain names into IP addresses. When you type a website name in the browser, DNS finds the correct IP address of that website so your computer can connect to the correct server.</p>
<p>Without DNS, we would need to remember IP addresses for every website, which is not practical.</p>
<h2 id="heading-what-is-the-dig-command-and-when-is-it-used"><strong>What is the dig command, and when is it used?</strong></h2>
<p><strong>dig</strong> (Domain Information Groper) is a command-line tool used to query DNS servers and inspect how name resolution works.</p>
<blockquote>
<p><strong>dig</strong> helps you <strong>check how DNS is working behind the scenes</strong>.</p>
</blockquote>
<p>It is mainly used by <strong>developers</strong>, <strong>system administrators</strong>, and <strong>network engineers</strong> to debug DNS problems, check name servers, and understand how DNS resolution is happening.</p>
<p>Using dig we can see:</p>
<ul>
<li><p>Which name servers are involved</p>
</li>
<li><p>Which records are returned</p>
</li>
<li><p>How the DNS query travels step by step</p>
</li>
</ul>
<p>Now, let’s understand how DNS resolution happens in layers.</p>
<h3 id="heading-understanding-dig-ns-and-root-name-servers"><strong>Understanding dig . NS and root name servers</strong></h3>
<pre><code class="lang-bash">dig . NS
</code></pre>
<p><strong>dig</strong> tells about who the <strong>name servers</strong> are for the root of the <strong>DNS</strong> system.</p>
<p>The dot <strong>(.)</strong> represents the root server.<br />Root name servers are the <strong>top-level</strong> servers in the DNS hierarchy.</p>
<p>They store only <strong>TLDs</strong> and do not know the IP addresses of websites.<br />They only know where to find <strong>TLD (Top-Level Domain)</strong> servers such as .com, .co, .in, etc.</p>
<p>Root servers are the starting point of every DNS lookup.</p>
<h3 id="heading-understanding-dig-com-ns-and-tld-name-servers"><strong>Understanding dig com NS and TLD name servers</strong></h3>
<pre><code class="lang-bash">dig com NS
</code></pre>
<p>This command asks the <strong>name servers</strong>: Who manages the .com domain?</p>
<p>The <strong>name server’s</strong> response gives the list of <strong>TLD</strong> name servers responsible for all .com websites.</p>
<p>These servers do not know the IP address of <a target="_blank" href="http://google.com">google.com</a> yet.</p>
<p>They only know where the <strong>authoritative servers</strong> for <a target="_blank" href="http://google.com">google.com</a> are located.</p>
<p>So now we move one layer deeper.</p>
<h2 id="heading-understanding-dig-googlecomhttpgooglecom-ns-and-authttpgooglecomhoritative-name-servers"><strong>Understanding dig</strong> <a target="_blank" href="http://google.com"><strong>google.com</strong></a> <a target="_blank" href="http://google.com/"><strong>NS and aut</strong></a><strong>horitative name servers</strong></h2>
<pre><code class="lang-bash">dig google.com NS
</code></pre>
<p>This command asks: Which name servers are responsible for <a target="_blank" href="http://google.com"><strong>google.com</strong></a>?</p>
<p>The result gives the authoritative name servers for <a target="_blank" href="http://google.com/"><strong>google.com</strong></a>.</p>
<p>These servers are the final authority for <a target="_blank" href="http://google.com/"><strong>google.com</strong></a>.</p>
<p>They store the actual DNS records, such as:</p>
<ul>
<li><p>IP addresses</p>
</li>
<li><p>Mail servers</p>
</li>
<li><p>Other DNS information</p>
</li>
</ul>
<p>Now we are very close to the final answer.</p>
<h2 id="heading-understanding-dig-googlecomhttpgooglecom-and-the-full-dns-resolution-flow">Understanding dig <a target="_blank" href="http://google.com">google.com</a> and the full DNS resolution flow</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769625950548/028863b0-5302-43a2-9479-3c742bafe578.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">dig google.com
</code></pre>
<p>This command asks (enquires) directly for the IP address of <a target="_blank" href="http://google.com">google.com</a></p>
<p>Behind the scenes, the <strong>DNS resolver</strong> follows this path:</p>
<ol>
<li><p>First, it enquires the <strong>root</strong> server.<br /> <strong>Root</strong> server replies with <strong>TLD</strong> servers for .com.</p>
</li>
<li><p>Then it enquires a <strong>.com</strong> TLD server.<br /> TLD server replies with <strong>authoritative</strong> servers for <a target="_blank" href="http://google.com/"><strong>google.com</strong></a>.</p>
</li>
<li><p>Then it enquires an <strong>authoritative</strong> server for <a target="_blank" href="http://google.com/"><strong>google.com</strong></a>.<br /> <strong>Authoritative</strong> server replies with the final <strong>IP address</strong>.</p>
</li>
</ol>
<p>Finally, the <strong>DNS resolver</strong> returns the <strong>IP address</strong> to your computer.</p>
<p>Now your browser can connect to the correct web server and load the website.</p>
<h2 id="heading-what-ns-records-represent-and-why-they-matter"><strong>What NS records represent and why they matter</strong></h2>
<p><strong>NS (Name Server)</strong> records tell which servers are responsible for a domain.</p>
<ul>
<li><p>They define who controls the domain</p>
</li>
<li><p>They guide the resolver to the correct authoritative servers</p>
</li>
<li><p>Without correct NS records, websites will not resolve</p>
</li>
</ul>
<h3 id="heading-how-recursive-resolvers-use-this-information"><strong>How recursive resolvers use this information</strong></h3>
<p>Your computer does not directly talk to root servers.</p>
<p>It sends the query to a recursive resolver (usually provided by your ISP or Google DNS).</p>
<p>The recursive resolver:</p>
<ul>
<li><p>Starts from the root servers</p>
</li>
<li><p>Goes to TLD servers</p>
</li>
<li><p>Goes to authoritative servers</p>
</li>
<li><p>Caches the result for future use(reference)</p>
</li>
</ul>
<p>This makes DNS faster and more efficient for repeated requests.</p>
<h2 id="heading-connecting-dig-googlecomhttpgooglecom-to-real-browser-requests"><strong>Connecting dig</strong> <a target="_blank" href="http://google.com"><strong>google.com</strong></a> <strong>to real browser requests</strong></h2>
<p>When you type <a target="_blank" href="http://google.com">google.com</a> in browser’s tab, the following DNS process happens.</p>
<p><strong>Browser → Recursive DNS Resolver<br />DNS Resolver → Root Server → TLD Server → Authoritative Server<br />Authoritative → IP Address returned<br />Browser → Connects to server using TCP<br />Website loads</strong></p>
<p>So every web request depends on DNS before any (communication) data transfer starts.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p><strong>DNS</strong> is the hidden system that makes the Internet usable by converting names into <strong>IP addresses</strong> and <strong>vice versa</strong>. The <strong>dig</strong> command helps us to see how <strong>DNS</strong> resolution works step by step, from root servers to authoritative servers.</p>
<p>Understanding this flow gives a clear picture of how browsers find the correct servers and how the Internet routes requests correctly whenever you open a website.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Common Networking Devices]]></title><description><![CDATA[Introduction
Have you ever thought about how we communicate to the world? It’s the internet, a mega network of networks in the computer world. When you open a website or use an application, the internet doesn’t reach your device magically. It passes ...]]></description><link>https://devasif-7.hashnode.dev/understanding-common-networking-devices</link><guid isPermaLink="true">https://devasif-7.hashnode.dev/understanding-common-networking-devices</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Mon, 26 Jan 2026 19:35:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769184757985/34f63c24-0b1f-44e1-9799-12af497a698b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Have you ever thought about how we communicate to the world? It’s the <strong>internet, a</strong> mega network of networks in the computer world. When you open a website or use an application, the internet doesn’t reach your device magically. It passes through a series of networking devices, each device has a specific responsibility to move data from the <strong>Global</strong> internet to your device.</p>
<p>Understanding of these for software engineers is important. Because many systems like <strong>Backend Systems</strong>, <strong>APIs</strong>, and <strong>Cloud Engineering etc are deeply connected to it.</strong></p>
<p>In this article, we will understand the most important networking devices like <strong>modem</strong>, <strong>router</strong>, <strong>switch</strong>, <strong>firewall</strong>, <strong>load-balancer,</strong> etc. How do they work together in real world setup?</p>
<h2 id="heading-how-does-the-internet-reach-your-home-or-office">How does the internet reach your home or office?</h2>
<p>If we see the high level view of internet. It starts from <strong>ISP</strong>(Internet Service Provider - Airtel, VI, BSNL, Jio etc). The Internet doesn’t directly reach your device; it passes through networking devices, each device has a specific responsibility. These devices work together to move data from the global internet to your <strong>PC</strong> or <strong>Mobile phone</strong>.</p>
<p>In this flow each device has a clear job. Some device connects to the internet and some translates the coming signals from ISP, some routes the traffic. To understand this flow make easier why so many devices exist?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769341747925/91af2fa9-8bb9-4d8f-8e20-7da04d034f3d.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-a-modem-and-how-it-connects-you-to-the-internet"><strong>What Is a Modem and How It Connects You to the Internet?</strong></h2>
<p>Modem (<em>modulator-demodulator)</em> a device that connects your home or office network to the internet.</p>
<p>The signals are coming from ISP <strong>(Analog Signals)</strong> are not understandable to your device. It changes these signals into <strong>(Digital signals)</strong> suitable to your device, so that your device can read the data coming from the internet. The modem converts <strong>analog</strong> signals into <strong>Digital</strong> signals and vice-versa.</p>
<p>You can think <strong>modem</strong> as a translator. It ensures smooth communication between <strong>ISP</strong> and your device. Suppose <strong>ISP</strong> speaks one language and your <strong>device</strong> speaks another. The modem ensures both sides understand and communicate each other.</p>
<p>For software engineer, it draws a line between your system and public internet.</p>
<h2 id="heading-what-is-a-router-and-how-it-directs-traffic">What is a Router and how it directs traffic?</h2>
<p>When the internet reaches to your <strong>network</strong> through <strong>modem</strong>, it <strong>forwards</strong> to the <strong>router</strong>.</p>
<p>Now the router controls the flow / traffic of data. It decides where <strong>data</strong> should <strong>go</strong>? It receives the incoming traffic / data and forwards it to the correct device by examining <strong>IP address</strong>. When your devices sends data out, the router ensures that it should reach the correct destination.</p>
<p>Backend developers should aware of it because routers play a very important in data routing. They handle:</p>
<ul>
<li><p>Examine IP address and forward the data</p>
</li>
<li><p>It Separates public and private network</p>
</li>
<li><p>Directing Data Traffic</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769349653128/7dca09a0-21b6-48c8-9538-ab76b17370b7.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-switch-vs-hub-how-local-networks-actually-work">Switch vs Hub: how local networks actually work?</h2>
<p>There is a need of communication of devices with each other inside a local network. <strong>Hubs</strong> and <strong>switches</strong> fulfill this need.</p>
<p>A <strong>Hub</strong> is a networking device with many ports. It helps to connect several devices to a single network. It’s use to receive data, it broadcasts that data to all connected devices, whether they need it or not. This function of <strong>hub</strong> makes it inefficient and noisy.</p>
<p>Unlike a hub, a <strong>switch</strong> is an intelligent networking device that connects multiple devices on a single Local Area Network (LAN). It identifies exactly which device is connected to which port, ensuring that data is sent only to the intended recipient rather than broadcasting it to everyone.</p>
<p>You can think of:</p>
<ul>
<li><p><strong>Hub:</strong> A hub functions by <strong>broadcasting</strong> raw data to <strong>every connected port</strong>, creating unnecessary network traffic.</p>
</li>
<li><p><strong>Switch:</strong> A switch establishes a <strong>dedicated connection</strong> for each data, ensuring it reaches <strong>only the specific destination device</strong>.</p>
</li>
</ul>
<p>Modern networks use switches almost everywhere because performance and efficiency matter</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769446978127/bb0a5815-2a97-4bb3-9d9d-7d2765c074d9.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-a-firewall-and-why-security-lives-here">What is a Firewall and why security lives here?</h2>
<p>Firewall acts as a security guard for your network, it is available as hardware and software as well.</p>
<p>It does filter the incoming and outgoing traffic and decides what should be allowed or blocked based on predefined rules. Firewall protects networks from unauthorized access, malicious traffic, and accidental exposure.</p>
<p>Imagine firewall as a security guard at the entrance of the building, checking who is allowed or not.</p>
<p>For backend systems, firewalls are critical because they:</p>
<ul>
<li><p>Protect <strong>databases</strong> and internal services</p>
</li>
<li><p>Restrict access to sensitive <strong>APIs</strong></p>
</li>
<li><p>Reduce attack <strong>surfaces</strong> in production environments</p>
</li>
</ul>
<p>Most security <strong>policies</strong> are enforced at this layer.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769454208449/884e7a88-5a91-4a82-a8e6-61d06b6fa309.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-a-load-balancer-and-why-scalable-systems-need-it">What is a Load Balancer and why scalable systems need it?</h2>
<p>As the applications grow (user increases), a single can not handle the traffic (requests/data). Load balancers handle this traffic easily and app runs smoothly.</p>
<p>A load balancer deploys in front of multiple servers that distributes incoming traffic among them. This ensures no single server is overloaded and the system remains available even if one server fails.</p>
<p>For software engineers, load balancers are essential for:</p>
<ul>
<li><p>High availability</p>
</li>
<li><p>Horizontal scaling</p>
</li>
<li><p>Zero-downtime deployments</p>
</li>
</ul>
<p>Almost all large production systems rely on them.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769455113788/f559bb0b-79d6-4fbe-b499-cd485db693c4.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-how-all-these-devices-work-together-in-a-real-world-setup">How all these devices work together in a real-world setup?</h2>
<p>In a real-world setup, these devices are not isolated. They form a pipeline through which data flow(move).</p>
<p>The typical flow looks like this:</p>
<ul>
<li><p>Internet traffic enters through the <strong>modem</strong></p>
</li>
<li><p>The <strong>router</strong> directs traffic into the local network</p>
</li>
<li><p>A <strong>firewall</strong> filters and secures the traffic</p>
</li>
<li><p>A <strong>switch</strong> connects multiple internal devices</p>
</li>
<li><p>A <strong>load balancer</strong> distributes requests across servers</p>
</li>
</ul>
<p>This layered design makes systems modular, secure, and scalable.</p>
<h2 id="heading-why-these-devices-matters-for-software-engineers"><strong>Why These devices Matters for Software Engineers</strong></h2>
<p>Even if you never configure networking hardware yourself, these concepts directly affect your work.</p>
<p>Backend developers deal with:</p>
<ul>
<li><p>Latency and timeouts</p>
</li>
<li><p>Network failures</p>
</li>
<li><p>Security rules</p>
</li>
<li><p>Traffic spikes</p>
</li>
</ul>
<p>Understanding where each device sits helps you find (reason) about production issues and design better systems. Many mysterious bugs are actually network behavior that makes perfect sense once you understand the architecture.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769456033366/1d9b7d98-2ac9-4bec-9f9f-569076ccd607.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item></channel></rss>