<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Moinul Islam</title>
    <description>The latest articles on DEV Community by Moinul Islam (@moinulislam7).</description>
    <link>https://dev.to/moinulislam7</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1680090%2Fc8c11f80-d110-4e0f-bc41-bcdf47d67268.jpg</url>
      <title>DEV Community: Moinul Islam</title>
      <link>https://dev.to/moinulislam7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/moinulislam7"/>
    <language>en</language>
    <item>
      <title>Understanding Hoisting in JavaScript</title>
      <dc:creator>Moinul Islam</dc:creator>
      <pubDate>Sun, 15 Jun 2025 11:52:06 +0000</pubDate>
      <link>https://dev.to/moinulislam7/understanding-hoisting-in-javascript-27ip</link>
      <guid>https://dev.to/moinulislam7/understanding-hoisting-in-javascript-27ip</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Hoisting?&lt;/strong&gt;&lt;br&gt;
Hoisting is JavaScript's default behavior of moving declarations (not initializations) to the top of their scope during the compile phase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Hoisting Works (Two Phases)?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Compile Phase&lt;/strong&gt;&lt;br&gt;
Before executing your code, JavaScript scans the entire scope and sets up memory for all declared variables and functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;var&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declaration is hoisted and initialized as &lt;code&gt;undefined&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You can access it before the line, but the value will be &lt;code&gt;undefined&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;let and const&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declaration is hoisted, but not initialized&lt;/li&gt;
&lt;li&gt;They stay in a &lt;code&gt;Temporal Dead Zone (TDZ)&lt;/code&gt; until their actual line&lt;/li&gt;
&lt;li&gt;Accessing them before declaration throws a &lt;code&gt;ReferenceError&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Function Declarations&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;entire function (name + body)&lt;/code&gt; is hoisted&lt;/li&gt;
&lt;li&gt;You can safely call the function before its declaration&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Execution Phase&lt;/strong&gt;&lt;br&gt;
Now JavaScript executes your code line-by-line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; variables receive their assigned value&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;let&lt;/code&gt; / &lt;code&gt;const&lt;/code&gt; are initialized at their declaration line&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;let&lt;/code&gt; / &lt;code&gt;const&lt;/code&gt; before this point causes an error due to TDZ&lt;/li&gt;
&lt;li&gt;Hoisted functions (declared with &lt;code&gt;function&lt;/code&gt;) can be called anytime&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;TDZ (Temporal Dead Zone)&lt;/strong&gt;&lt;br&gt;
let and const are hoisted, so you can’t use them before the line they are declared or it gives an error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(a);        // undefined (var is hoisted)
console.log(b);        // ReferenceError (let is in TDZ)
console.log(greet());  // "Hello" (function is hoisted)

var a = 10;
let b = 20;

function greet() {
  return "Hello";
}

var sayHi = function () {
  return "Hi";
};

console.log(sayHi());  // "Hi" (works only after assignment)
sole.log("Bye!");
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqb8cmoxa0faw4wj8gli.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqb8cmoxa0faw4wj8gli.png" alt=" " width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>HIDDEN WEBSITES FOR PROGRAMMERS</title>
      <dc:creator>Moinul Islam</dc:creator>
      <pubDate>Tue, 25 Jun 2024 09:12:49 +0000</pubDate>
      <link>https://dev.to/moinulislam7/hidden-websites-forprogrammers-2a3n</link>
      <guid>https://dev.to/moinulislam7/hidden-websites-forprogrammers-2a3n</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;a href="https://devdocs.io/" rel="noopener noreferrer"&gt;devdocs.io&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;DevDocs brings together numerous API documentation in a single, searchable interface. You will find docs related to various programming languages and technologies in one place.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn88af1no6qjjoygwr5i4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn88af1no6qjjoygwr5i4.png" alt=" " width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://css-tricks.com/" rel="noopener noreferrer"&gt;css-tricks.com&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
You can master your web development skills by learning everything about CSS from this website. If you didn't already know, CSS is what makes pages on the web look beautiful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppd1k4zdquunrk9hiqri.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppd1k4zdquunrk9hiqri.png" alt=" " width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://overapi.com/" rel="noopener noreferrer"&gt;overapi.com&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
OverAPI is one of the most beautiful and useful websites for all developers. This website has cheat sheets for the majority of programming languages. Please take a look at it right now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fynyq6r7x47b9vi3b3gvo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fynyq6r7x47b9vi3b3gvo.png" alt=" " width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
