<?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: Rafsan Jany Ratul</title>
    <description>The latest articles on DEV Community by Rafsan Jany Ratul (@rafsan-jany-ratul).</description>
    <link>https://dev.to/rafsan-jany-ratul</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%2F3498858%2Fda0594e6-9bb8-4b66-b789-05464c1c88ee.jpg</url>
      <title>DEV Community: Rafsan Jany Ratul</title>
      <link>https://dev.to/rafsan-jany-ratul</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rafsan-jany-ratul"/>
    <language>en</language>
    <item>
      <title>Understanding Scope, Hoisting, and Closures like a Pro!</title>
      <dc:creator>Rafsan Jany Ratul</dc:creator>
      <pubDate>Sun, 05 Apr 2026 08:00:46 +0000</pubDate>
      <link>https://dev.to/rafsan-jany-ratul/understanding-scope-hoisting-and-closures-like-a-pro-152h</link>
      <guid>https://dev.to/rafsan-jany-ratul/understanding-scope-hoisting-and-closures-like-a-pro-152h</guid>
      <description>&lt;p&gt;🔹 &lt;strong&gt;What is Scope?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scope defines the accessibility of variables in your code.&lt;/p&gt;

&lt;p&gt;Simply put:&lt;/p&gt;

&lt;p&gt;Scope decides where in your code a variable can be used.&lt;/p&gt;

&lt;p&gt;In JavaScript, every variable has a “boundary.” Outside this boundary, the variable is unavailable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is Scope important?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prevent variable conflicts&lt;/li&gt;
&lt;li&gt;Manage memory efficiently&lt;/li&gt;
&lt;li&gt;Make code predictable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Main types of Scope:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global Scope&lt;/strong&gt; → accessible from anywhere&lt;br&gt;
&lt;strong&gt;Function Scope&lt;/strong&gt; → accessible only within a function&lt;br&gt;
&lt;strong&gt;Block Scope&lt;/strong&gt; → accessible within {} (using let or const)&lt;br&gt;
&lt;strong&gt;Lexical Scope&lt;/strong&gt; → determined by the code’s written structure&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔹 Scope Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// global scope&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// function scope&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;result1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// function scope (var)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// accessible&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// global access&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ Error, function scope&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Takeaways:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;result&lt;/code&gt; is limited to the &lt;strong&gt;function scope&lt;/strong&gt;, so it cannot be accessed outside the function&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;result1&lt;/code&gt; is accessible inside the function &lt;strong&gt;not because of hoisting&lt;/strong&gt;, but because &lt;code&gt;var&lt;/code&gt; is &lt;strong&gt;function-scoped&lt;/strong&gt; (it ignores block scope)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;person&lt;/code&gt; can be accessed inside the function because it is declared in the &lt;strong&gt;global scope&lt;/strong&gt;, and global variables are accessible from anywhere&lt;/li&gt;
&lt;li&gt;JavaScript follows a &lt;strong&gt;scope chain&lt;/strong&gt;, meaning it first looks for variables in the local scope, and if not found, it checks the outer (global) scope&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Block scope&lt;/strong&gt; refers to any code inside &lt;code&gt;{}&lt;/code&gt; — such as &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;else&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt;, or &lt;code&gt;while&lt;/code&gt; blocks — where &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are limited to that block only&lt;/li&gt;
&lt;li&gt;A function also creates its own scope, and blocks inside functions can act as &lt;strong&gt;block scope&lt;/strong&gt; when using &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt;, &lt;code&gt;let&lt;/code&gt;, and &lt;code&gt;const&lt;/code&gt; have different scoping rules, so choosing the right one is important for predictable behavior&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;🔹 What is Hoisting?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hoisting is JavaScript’s behavior where variable and function declarations are moved to memory at the beginning of the execution phase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In other words:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before your code runs, JS prepares memory for all declared variables and functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important points:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;var&lt;/strong&gt; → hoisted and initialized as undefined&lt;br&gt;
&lt;strong&gt;let / const&lt;/strong&gt; → hoisted but not initialized (they stay in the Temporal Dead Zone)&lt;br&gt;
&lt;strong&gt;Function declarations&lt;/strong&gt; → fully hoisted&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common misconception:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some think hoisting literally “moves code to the top,” but technically, it’s a memory preparation process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔹 Hoisting Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// undefined&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Internally, JavaScript interprets it as:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// undefined&lt;/span&gt;
&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using let or const:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ ReferenceError&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This happens because let/const are hoisted but not initialized, creating the Temporal Dead Zone (TDZ).&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;🔹 What are Closures?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A closure is when a function “remembers” variables from its outer scope even after the outer function has finished executing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simply:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Function + its surrounding environment = Closure&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why closures are useful:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Maintain private data&lt;/p&gt;

&lt;p&gt;Keep state between function calls&lt;/p&gt;

&lt;p&gt;Widely used in real-world JS (event handlers, React hooks, etc.) &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔹 Closure Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;total&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nl"&gt;Usage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;


&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;total&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nf"&gt;result1&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;span class="nf"&gt;result1&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// 2&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;total&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nf"&gt;result2&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;span class="nf"&gt;result1&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key points:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;counter is not global&lt;/p&gt;

&lt;p&gt;The inner function remembers its value&lt;/p&gt;

&lt;p&gt;Each call to total() creates a new memory instance&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;🔹 Lexical Scope (The backbone of closures)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;outer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;inner&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The inner function is declared inside the outer function&lt;/p&gt;

&lt;p&gt;Therefore, it can access variable a&lt;/p&gt;

&lt;p&gt;This is lexical scope, which allows closures to work&lt;br&gt;
 How These Concepts Connect&lt;br&gt;
Scope → defines where a variable lives&lt;br&gt;
Lexical Scope → defines what variables a function can access based on the written code&lt;br&gt;
Closure → allows functions to “remember” variables from outer scopes&lt;br&gt;
All three work together in JavaScript!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scope&lt;/strong&gt; → variable boundaries&lt;br&gt;
&lt;strong&gt;Hoisting&lt;/strong&gt; → memory preparation before execution&lt;br&gt;
&lt;strong&gt;Lexical Scope&lt;/strong&gt; → determines access based on code structure&lt;br&gt;
&lt;strong&gt;Closure&lt;/strong&gt; → functions remember outer data&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Thought&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Many unexpected behaviors in JavaScript happen because these concepts are unclear.&lt;/p&gt;

&lt;p&gt;Once Scope, Hoisting, Lexical Scope, and Closures are understood, JavaScript becomes predictable and much easier to work with&lt;br&gt;
  #webdevelopment #frontend #closure #hoisting #scope #lexicalscope #learntocode&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>scope</category>
      <category>clouser</category>
    </item>
    <item>
      <title>JavaScript Event Loop Explained (Call Stack, setTimeout, Promise, async/await)</title>
      <dc:creator>Rafsan Jany Ratul</dc:creator>
      <pubDate>Thu, 02 Apr 2026 06:17:21 +0000</pubDate>
      <link>https://dev.to/rafsan-jany-ratul/javascript-event-loop-explained-call-stack-settimeout-promise-asyncawait-38gj</link>
      <guid>https://dev.to/rafsan-jany-ratul/javascript-event-loop-explained-call-stack-settimeout-promise-asyncawait-38gj</guid>
      <description>&lt;p&gt;JavaScript is single-threaded, but it can still handle asynchronous operations like timers, API calls, and promises efficiently. This often confuses developers — especially when &lt;code&gt;setTimeout&lt;/code&gt;, &lt;code&gt;Promise&lt;/code&gt;, and &lt;code&gt;async/await&lt;/code&gt; don’t execute in the order we expect.&lt;/p&gt;

&lt;p&gt;In this article, we will break down how JavaScript actually works behind the scenes using the Call Stack, Web APIs, Callback Queue, Microtask Queue, and the Event Loop.&lt;/p&gt;

&lt;p&gt;We will start with a simple synchronous example, then gradually move into asynchronous behavior using &lt;code&gt;setTimeout&lt;/code&gt;, &lt;code&gt;Promise&lt;/code&gt;, and &lt;code&gt;async/await&lt;/code&gt;. By the end, you will clearly understand why some code runs immediately while other parts are delayed — and how JavaScript manages everything without blocking the main thread.&lt;/p&gt;

&lt;p&gt;If you've ever wondered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why does &lt;code&gt;setTimeout&lt;/code&gt; run last?&lt;/li&gt;
&lt;li&gt;Why does &lt;code&gt;Promise.then()&lt;/code&gt; run before &lt;code&gt;setTimeout&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;Does &lt;code&gt;async/await&lt;/code&gt; make code synchronous?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then this guide is for you&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 1: Synchronous vs setTimeout
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;a&lt;/span&gt; &lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nf"&gt;b&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;first&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;b&lt;/span&gt; &lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nf"&gt;d&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;second&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;async task1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;async task2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;d&lt;/span&gt; &lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nf"&gt;e&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fourth&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;e&lt;/span&gt; &lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fifth&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;a&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;JavaScript is &lt;strong&gt;single-threaded&lt;/strong&gt;, meaning it uses one &lt;strong&gt;Call Stack&lt;/strong&gt; to execute code.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔹 Step 1: Synchronous Execution
&lt;/h3&gt;

&lt;p&gt;Functions run one by one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a() → b() → d() → e()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fifth
fourth
second
first
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🔹 Step 2: setTimeout Behavior
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;setTimeout&lt;/code&gt; is handled by &lt;strong&gt;Web APIs&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;After the timer finishes, it goes to the &lt;strong&gt;Callback Queue&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Event Loop&lt;/strong&gt; moves it to the Call Stack when it's empty&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Final Output:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fifth
fourth
second
first
async task2
async task1


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Event Loop (Simple Idea)
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;The Event Loop continuously checks:&lt;br&gt;
“Is the Call Stack empty?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If yes → it pushes tasks from the queue into the stack.&lt;/p&gt;




&lt;h2&gt;
  
  
  Example 2: Promise (Microtask Queue)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;timeout&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;promise&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;end&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start
end
promise
timeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Why This Happens?
&lt;/h2&gt;

&lt;p&gt;Because JavaScript has &lt;strong&gt;two queues&lt;/strong&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  🟡 Microtask Queue
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Promise &lt;code&gt;.then&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;async/await&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔵 Callback Queue (Macrotask)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;setTimeout&lt;/li&gt;
&lt;li&gt;setInterval&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Rule:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Microtasks always run before Callback Queue tasks.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Example 3: async/await
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;end&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;before&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;after&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;before
start
after
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Important Concept
&lt;/h2&gt;

&lt;p&gt;Many people think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;async/await makes code synchronous&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;❌ That’s incorrect&lt;/p&gt;

&lt;p&gt;✔️ Correct idea:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;async/await makes asynchronous code LOOK synchronous, but it still uses the Event Loop.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript runs synchronous code first&lt;/li&gt;
&lt;li&gt;Async tasks go to Web APIs&lt;/li&gt;
&lt;li&gt;Event Loop manages execution&lt;/li&gt;
&lt;li&gt;Promises use &lt;strong&gt;Microtask Queue&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Microtasks run before setTimeout&lt;/li&gt;
&lt;li&gt;async/await is just syntax over Promise&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Thought
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;JavaScript never pauses the entire program for async code.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It simply schedules it smartly using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Call Stack&lt;/li&gt;
&lt;li&gt;Event Loop&lt;/li&gt;
&lt;li&gt;Queues&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you understand this, async JavaScript becomes much easier&lt;/p&gt;




&lt;p&gt;If this helped you, feel free to share&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to build your first web project like a Pro</title>
      <dc:creator>Rafsan Jany Ratul</dc:creator>
      <pubDate>Thu, 30 Oct 2025 08:10:56 +0000</pubDate>
      <link>https://dev.to/rafsan-jany-ratul/how-to-build-your-first-web-project-like-a-pro-44gl</link>
      <guid>https://dev.to/rafsan-jany-ratul/how-to-build-your-first-web-project-like-a-pro-44gl</guid>
      <description>&lt;p&gt;when we build our first web project, sometimes we see that every file we create stays together at the same place but it is not a good practise. When we drop a HTML,CSS,image file together in one folder then when our project grow there will be a chances of making mistake. In this article i will show you how to decorate your first website like a pro so that in future when we move to MERN or React it will be easier to handle everything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Making clean folder structure&lt;/strong&gt;&lt;br&gt;
at the beginning of project, we have to setup our folders like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-project/
│
├── index.html
├── /assets
│   ├── /images
│   ├── /icons
│   └── /fonts
│
├── /css
│   ├── style.css
│   └── responsive.css
│
├── /js
│   ├── script.js
│   └── utils.js
│
└── /components
    ├── navbar.html
    └── footer.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it works well :&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;we can find our code easily&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;we can reuse the same component again when needed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;deployment will be easier on github pages or another hosting platforms&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. CSS files should be separate instead of creating one file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;in most cases we make mistake of writing all our code in one &lt;br&gt;
&lt;code&gt;style.css&lt;/code&gt; file.But if we do like that then when needed we have to face difficulty to find. To solve this problem we can divide files like that,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;style.css&lt;/code&gt; main design&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;responsive.css&lt;/code&gt; mobile and tabs design&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;animation.css&lt;/code&gt; if we use animation&lt;br&gt;
if we organize like that then it will be easier to maintain code and files.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Separate Javascript Files&lt;/strong&gt;&lt;br&gt;
We can organize JS files like that,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;script.js&lt;/code&gt; for DOM manipulation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;data.js&lt;/code&gt; for static data or objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;utils.js&lt;/code&gt; for helper functions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we do this our code will be modular, which will give us more flexiblity to learn React or Node.js&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. We have to reuse common component&lt;/strong&gt;&lt;br&gt;
In our project sometimes we have to reuse &lt;code&gt;navbar&lt;/code&gt; &lt;code&gt;footer&lt;/code&gt;&lt;br&gt;
or &lt;code&gt;header&lt;/code&gt; for better practise, we need to separate these files like &lt;code&gt;navbar.html&lt;/code&gt;, &lt;code&gt;footer.html&lt;/code&gt; &lt;br&gt;
If we want then we can include this automated using tamplate engine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Naming and code style will be same&lt;/strong&gt;&lt;br&gt;
it is important to maintain when we making a project&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;every folder and files name will be in lowercase&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;avoid space use hyphen(-) like, &lt;code&gt;main-section&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;we have to indent HTML/CSS properly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;we have to maintain same naming convention&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6. Version Control using form the first day&lt;/strong&gt;&lt;br&gt;
in our first froject we should use git and github. We dont need to be expart in this time but learn the basics&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git add .
git commit -m "Initial commit"
git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backup your work&lt;/li&gt;
&lt;li&gt;Track changes&lt;/li&gt;
&lt;li&gt;Show your projects publicly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;7. Bonus: Recommended Folder Setup for Larger Projects&lt;/strong&gt;&lt;br&gt;
When you move into React or Node.js later, you’ll see similar structures — so learning it now gives you a big head start.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;project/
├── public/
├── src/
│   ├── components/
│   ├── pages/
│   ├── styles/
│   ├── scripts/
│   └── utils/
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so start simple but think like a pro&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
At the first time we may think that organize file structure is a extra work and boaring but after some days we will understand that it will increase our productivity more.&lt;br&gt;
when a project folder we open and see every files are organized then it show that someone professional who write the code clearly and better way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now your Turns&lt;/strong&gt;&lt;br&gt;
How do you organize your project folders?&lt;br&gt;
Do you prefer everything in one place, or a modular structure?&lt;br&gt;
Share your setup in the comments — I’d love to see how others do it!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>frontend</category>
      <category>javascript</category>
    </item>
    <item>
      <title>8 Things You Should Know About Responsive Web Design</title>
      <dc:creator>Rafsan Jany Ratul</dc:creator>
      <pubDate>Wed, 22 Oct 2025 20:09:21 +0000</pubDate>
      <link>https://dev.to/rafsan-jany-ratul/8-things-you-should-know-about-responsive-web-design-34g2</link>
      <guid>https://dev.to/rafsan-jany-ratul/8-things-you-should-know-about-responsive-web-design-34g2</guid>
      <description>&lt;p&gt;Nowadays, when a user visits our website or web application using a mobile, tablet, or laptop — he should be able to use it comfortably. This is the main purpose of responsive web design.&lt;br&gt;
A website that looks good on a large screen but appears poor on a small screen cannot be considered a modern website.&lt;/p&gt;
&lt;h2&gt;
  
  
  How Responsive Design Works
&lt;/h2&gt;

&lt;p&gt;Responsive design means the layout, text, images, buttons, etc. will adjust automatically according to the screen size.&lt;br&gt;
Here, we don't need to create separate versions for each screen size; rather, one design will work for every device.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Important Ways to Make a Website Responsive
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Mobile-First Approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have to start our design with small screens like mobile. Then, gradually, we can expand the design for larger screens.&lt;br&gt;
This way, performance looks better on small devices.&lt;br&gt;
However, if you want, you can select the desktop as the first approach and then gradually move towards smaller devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Viewport Meta Tag Usage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag of HTML, the viewport meta tag is required. The code looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It helps the website become responsive according to the device’s viewport.&lt;br&gt;
In most code editors, this tag is included by default — just make sure it’s present.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Using Max-Width for Layout Control and Center Alignment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On large screens, the website content should not be too wide horizontally, and on small screens, it should fit properly and look good.&lt;br&gt;
To ensure this, max-width is used. Additionally, people use margin: 0 auto; to center the content horizontally.&lt;br&gt;
By applying this technique, all content stays centered.&lt;br&gt;
You can also add some padding for small screens to create spacing, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every modern website uses this technique.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Relative Units and Flexible Layout&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We should use %, rem, or em instead of pixels.&lt;br&gt;
Pixels are fixed values. Though px can be used in some cases, for making a responsive website, relative units are more effective.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  width: 90%;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Using Flexbox and Grid Layout&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the past, people used float-based layouts, but nowadays, the simplest and most modern solution is using Flexbox and Grid.&lt;br&gt;
These are easier to maintain and offer better control for responsive design.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Making Images and Videos Fluid&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have to use relative units and avoid fixed pixel sizes for images.&lt;br&gt;
If we use %, the image becomes fluid and adjusts within its container — making it easier to build a responsive layout.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;img {
  max-width: 100%;
  height: auto;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Responsive Typography&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the screen is small, font sizes should also be smaller; otherwise, they will look oversized.&lt;br&gt;
Similarly, on larger screens, the font size should be appropriate.&lt;br&gt;
For this, we can use em, rem, or vw units.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Responsive Navigation Menu&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The navigation bar is one of the most important parts of a website.&lt;br&gt;
On desktop screens, horizontal menus look fine, but on small screens, they can break and become unreadable.&lt;br&gt;
To solve this problem, we need a responsive navigation design.&lt;/p&gt;

&lt;p&gt;We can use media queries for small screens and convert the menu layout into a vertical one.&lt;br&gt;
Then, using JavaScript, we can create a hamburger icon — when clicked, the menu will toggle on and off.&lt;br&gt;
We can also use Flexbox or Grid to align and control the order of menu items.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Responsive web design is now a mandatory part of modern web development.&lt;br&gt;
If we can properly use HTML, CSS, Flexbox, Grid, and Media Queries, we can build websites that work smoothly and beautifully across all screen sizes.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
      <category>responsive</category>
    </item>
    <item>
      <title>Let's Understand a Website URL What Are HTTP, Domain, Hosting, and More?</title>
      <dc:creator>Rafsan Jany Ratul</dc:creator>
      <pubDate>Wed, 22 Oct 2025 11:25:08 +0000</pubDate>
      <link>https://dev.to/rafsan-jany-ratul/lets-understand-a-website-url-what-are-http-domain-hosting-and-more-1l72</link>
      <guid>https://dev.to/rafsan-jany-ratul/lets-understand-a-website-url-what-are-http-domain-hosting-and-more-1l72</guid>
      <description>&lt;p&gt;When we type a URL like&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://www.example.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and click enter then what will happens?&lt;/p&gt;

&lt;p&gt;Let’s break it down step by step and understand what each part actually means in the simplest way possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What is a URL?
&lt;/h2&gt;

&lt;p&gt;URL means Uniform Resource Locator&lt;br&gt;
this is mainly the address of the website like, our home address. In the internet there there also an address of the website.&lt;/p&gt;

&lt;p&gt;For example: &lt;code&gt;https://www.google.com&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What Does HTTP and HTTPS Mean?
&lt;/h2&gt;

&lt;p&gt;HTTP means Hyper Text Transfer Protocol. This is the system by which the browser and server are connected with each other. Then comes HTTPS, which means Hyper Text Transfer Protocol Secure. Here, S means Secure, which comes from the Secure Socket Layer (the short form of this is SSL). SSL ensures the security of data. In the very first time when HTTP was used, there were issues of losing data and man-in-the-middle attacks. That means data could be lost sometimes while passing. To remove the issue in the technology field, SSL was added. Now it has turned into HTTPS for security. That’s why every safe website starts with HTTPS.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. What Does “www” Mean?
&lt;/h2&gt;

&lt;p&gt;WWW means World Wide Web. It is a sub domain. It will connect the main server of the website. Now a days, people works without WWW like, google.com, facebook.com, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. What Is a Domain Name?
&lt;/h2&gt;

&lt;p&gt;Domain name is the readable address of the website what is easy to remember. for example, in &lt;code&gt;https://google.com&lt;/code&gt; &lt;br&gt;
google is the brand and .com is domain extension. you can say domain is google but .com is top level domain. the domain extension like.com, .net, .org, .edu  says the category of the website.&lt;br&gt;
when you hit a url like, &lt;code&gt;https://www.example.com&lt;/code&gt; then, first the server will find and reach to the top level domain .com then it will search the example under the .com domain.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. What Is Hosting?
&lt;/h2&gt;

&lt;p&gt;Hosting is the platform where the datas and files of the website like html css javascript database etc will reserved. Domain is the address of Home and hosting is the Home where we keep our furniture and items. when we hit an url then by the domain we can see the website what is remain in hosting.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Everything Works Together
&lt;/h2&gt;

&lt;p&gt;when we write &lt;code&gt;https://www.google.com&lt;/code&gt;&lt;br&gt;
then browser finds the ip of google.com by the DNS system. Then by HTTP/HTTPS protocol it will connect with the server. From the server the files of the website like HTML CSS JS are transferred. Then we see the website on the screen.&lt;/p&gt;

&lt;p&gt;These basic things are very important for the web developer because, making website means knowing how website works and be live on internet not only knowing html css.&lt;/p&gt;

&lt;p&gt;Thanks for reading! Follow me if you want to learn along!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>html</category>
      <category>https</category>
    </item>
  </channel>
</rss>
