<?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[debojyoti.dev]]></title><description><![CDATA[debojyoti.dev]]></description><link>https://blog.debojyoti.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 04:58:26 GMT</lastBuildDate><atom:link href="https://blog.debojyoti.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Javascript quick revision]]></title><description><![CDATA[Point-1: var vs let vs const – What's the Difference?
In JavaScript, var, let, and const are used to declare variables.There are 3 factors to analyze the differences between these keywords

Scope of variables:

Redeclaration and reassignment

Hoistin...]]></description><link>https://blog.debojyoti.dev/javascript-quick-revision</link><guid isPermaLink="true">https://blog.debojyoti.dev/javascript-quick-revision</guid><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Debojyoti Saha]]></dc:creator><pubDate>Wed, 14 Feb 2024 11:29:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707906606976/1a51171e-2847-4405-92b2-72c1942316cd.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-point-1-var-vs-let-vs-const-whats-the-difference"><strong>Point-1: var vs let vs const – What's the Difference?</strong></h3>
<p>In JavaScript, <code>var</code>, <code>let</code>, and <code>const</code> are used to declare variables.<br />There are 3 factors to analyze the differences between these keywords</p>
<ol>
<li><p>Scope of variables:</p>
</li>
<li><p>Redeclaration and reassignment</p>
</li>
<li><p>Hoisting</p>
</li>
</ol>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Feature</strong></td><td><code>var</code></td><td><code>let</code></td><td><code>const</code></td></tr>
</thead>
<tbody>
<tr>
<td>Scope</td><td>Function scope (accessible throughout the function they are declared in)</td><td>Block scope (accessible within the block they are declared in)</td><td>Block scope (accessible within the block they are declared in)</td></tr>
<tr>
<td>Redeclaration</td><td>Allowed (can be redeclared in the same scope)</td><td>Not allowed (results in SyntaxError)</td><td>Not allowed (results in SyntaxError)</td></tr>
<tr>
<td>Reassignment</td><td>Allowed (can be reassigned)</td><td>Allowed (can be reassigned)</td><td>Not allowed (cannot be reassigned)</td></tr>
<tr>
<td>Hoisting</td><td>Hoisted and initialized with <code>undefined</code></td><td>Hoisted but not initialized</td><td>Hoisted but not initialized</td></tr>
</tbody>
</table>
</div><h3 id="heading-point-2-datatypes-in-javascript"><strong>Point-2: Datatypes in javascript</strong></h3>
<p>In JavaScript, data types specify the type of data that can be stored and manipulated within the language. JavaScript is a loosely typed or a dynamic language, meaning variables do not need to be declared with a data type explicitly, and their data types can change during the execution of the program. JavaScript supports two categories of data types:</p>
<ol>
<li><p><strong>Primitive Data Types</strong>: These are the basic data types that hold a single value.</p>
<ul>
<li><p><strong>String</strong>: Represents textual data, e.g., <code>"Hello, World!"</code>.</p>
</li>
<li><p><strong>Number</strong>: Represents both integer and floating-point numbers, e.g., <code>42</code>, <code>3.14</code>.</p>
</li>
<li><p><strong>BigInt</strong>: Represents integers with arbitrary precision, e.g., <code>9007199254740991n</code>.</p>
</li>
<li><p><strong>Boolean</strong>: Represents a logical entity with two values: <code>true</code> and <code>false</code>.</p>
</li>
<li><p><strong>Undefined</strong>: Represents a variable that has not been assigned a value.</p>
</li>
<li><p><strong>Null</strong>: Represents the intentional absence of any object value.</p>
</li>
<li><p><strong>Symbol</strong>: Represents a unique, immutable identifier, often used as the key of an Object property.</p>
</li>
</ul>
</li>
<li><p><strong>Reference Data Types</strong> (Objects): These data types are used to store collections of data or more complex entities.</p>
<ul>
<li><p><strong>Object</strong>: Represents instances of named values, e.g., <code>{ name: "Alice", age: 30 }</code>.</p>
</li>
<li><p><strong>Array</strong>: A type of object used for storing sequences of values, e.g., <code>[1, 2, 3]</code>.</p>
</li>
<li><p><strong>Function</strong>: Represents code that can be called by other code or by itself, e.g., <code>function hello() { console.log("Hello, World!"); }</code>.</p>
</li>
</ul>
</li>
</ol>
<p>JavaScript dynamically determines the data type based on the value assigned to the variable, allowing for a flexible approach to programming but also requiring careful management to avoid unexpected behavior or bugs.</p>
<h3 id="heading-point-3-undefined-vs-null"><strong>Point-3: undefined vs null</strong></h3>
<p>In JavaScript, <code>undefined</code> and <code>null</code> both represent absence of value, but in different ways:</p>
<p><strong>Keypoint to remember</strong>: <code>undefined</code> represents the system-level, absent value, <code>null</code> is used by programmers to indicate the intentional absence of any object value.</p>
<p>Here's a table view summarizing the differences between <code>undefined</code> and <code>null</code> in JavaScript:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Aspect</strong></td><td><code>undefined</code></td><td><code>null</code></td></tr>
</thead>
<tbody>
<tr>
<td><strong>Description</strong></td><td>Indicates that a variable has not been assigned a value.</td><td>Explicitly represents the absence of any object value.</td></tr>
<tr>
<td><strong>Type</strong></td><td><code>"undefined"</code></td><td><code>"object"</code> (considered a legacy bug)</td></tr>
<tr>
<td><strong>Equality</strong></td><td><code>undefined == null</code> is <code>true</code> (non-strict equality)</td><td><code>undefined == null</code> is <code>true</code> (non-strict equality)</td></tr>
<tr>
<td></td><td><code>undefined === null</code> is <code>false</code> (strict equality)</td><td><code>undefined === null</code> is <code>false</code> (strict equality)</td></tr>
<tr>
<td><strong>Default Value</strong></td><td>Default value for uninitialized variables.</td><td>Can be assigned to a variable as a representation of no value.</td></tr>
<tr>
<td><strong>Function Return</strong></td><td>Functions return <code>undefined</code> if no value is specified.</td><td>Can be returned by a function to explicitly indicate no meaningful value.</td></tr>
<tr>
<td><strong>Usage</strong></td><td>Used by the JavaScript engine to denote absence of value.</td><td>Used by programmers to denote absence of value intentionally.</td></tr>
</tbody>
</table>
</div>]]></content:encoded></item></channel></rss>