<?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: Muhammad Burhan Chughtai</title>
    <description>The latest articles on DEV Community by Muhammad Burhan Chughtai (@burhan_chughtai).</description>
    <link>https://dev.to/burhan_chughtai</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%2F2100263%2F0896bc63-475d-4703-91b8-1320f2268bd0.JPG</url>
      <title>DEV Community: Muhammad Burhan Chughtai</title>
      <link>https://dev.to/burhan_chughtai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/burhan_chughtai"/>
    <language>en</language>
    <item>
      <title>"Var vs Let: The Big Confusion Explained!"</title>
      <dc:creator>Muhammad Burhan Chughtai</dc:creator>
      <pubDate>Sat, 07 Feb 2026 22:43:47 +0000</pubDate>
      <link>https://dev.to/burhan_chughtai/var-vs-let-the-big-confusion-explained-4hhk</link>
      <guid>https://dev.to/burhan_chughtai/var-vs-let-the-big-confusion-explained-4hhk</guid>
      <description>&lt;p&gt;&lt;em&gt;It's a clear thought about "Let" and "Var" concept&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Let:&lt;/strong&gt;&lt;br&gt;
You have mostly heard that &lt;em&gt;let&lt;/em&gt; it's a &lt;em&gt;blocked scope&lt;/em&gt;, so Yes but question is that, How exactly does it work. Mostly, developrs get stuck here - their mind goes blank.&lt;br&gt;
So, Don't worry I will show you exactly &lt;em&gt;let&lt;/em&gt; creates new variables per block, with simple example in loops, functions , and in closures.&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Loop Example (Per-Iteration New Variable)
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (let i = 0; i &amp;lt; 3; i++) {
  setTimeout(() =&amp;gt; console.log(i), 0);
}
// Output: 0, 1, 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Function Example (Block Shadowing)
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function test() {
  let x = 10;           // Outer x

  if (true) {
    let x = 20;         // New x (shadows outer x)
    console.log(x);     // 20
  }

  console.log(x);       // 10 (outer x unchanged)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;u&gt;" let variables &lt;strong&gt;cannot be accessed from outer scopes&lt;/strong&gt; after their block ends."&lt;br&gt;
&lt;/u&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Closure Example (Each Block Independent)
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function createClosures() {
  const closures = [];

  for (let i = 0; i &amp;lt; 3; i++) {
    closures.push(() =&amp;gt; console.log(i));  // Har i ka apna closure
  }

  closures[0](); // 0
  closures[1](); // 1  
  closures[2](); // 2
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;u&gt;&lt;em&gt;Closure&lt;/em&gt; it's a function that remember the outer function scope's variable.&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Var:&lt;/strong&gt;&lt;br&gt;
Now let's clear up the biggest confusion about var—why when use in loop and give condition " &amp;lt;= 3 " then it prints 3, 3, 3 in loops and drives everyone crazy!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (var i = 0; i &amp;lt; 3; i++) {
  setTimeout(() =&amp;gt; console.log(i), 0);
}
// Output: 3, 3, 3 
Step-by-Step What Happens:
Iteration 1: var i = 0  ← ONE variable created
Iteration 2: i = 1      ← Same variable, value CHANGED  
Iteration 3: i = 2      ← Same variable, value CHANGED
Loop ends:   i = 3      ← Final value

All 3 timeouts run → console.log(i) = 3 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Var Function Scope Example:
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function test() {
  if (true) {
    var x = 10;     // Function scope, NOT block scope
  }
  console.log(x);   // 10 - Accessible everywhere in function
}

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Var vs Let - The Real Difference&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
| Situation           | var                | let                    |
| ------------------- | ------------------ | ---------------------- |
| Loop + setTimeout   | 3, 3, 3            | 0, 1, 2                |
| Inside { if } block | Accessible outside |  ReferenceError       |
| Same name in blocks | Same variable      | New variable each time |
| Scope               | Function/Global    | Block only             |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final In-Short:&lt;/strong&gt;&lt;br&gt;
var = One variable that changes value &lt;br&gt;
let = New variable every block&lt;br&gt;
I've attached a helpful video demo: &lt;a href="https://www.youtube.com/watch?v=1mgLWu69ijU" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=1mgLWu69ijU&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>react</category>
      <category>node</category>
    </item>
    <item>
      <title>Solve Headache Backend API Authentication with Proven NPM Packages</title>
      <dc:creator>Muhammad Burhan Chughtai</dc:creator>
      <pubDate>Thu, 05 Feb 2026 01:56:09 +0000</pubDate>
      <link>https://dev.to/burhan_chughtai/solve-headache-backend-api-authentication-with-proven-npm-packages-46ff</link>
      <guid>https://dev.to/burhan_chughtai/solve-headache-backend-api-authentication-with-proven-npm-packages-46ff</guid>
      <description>&lt;p&gt;Let's Define That,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NPM Package : &lt;code&gt;npm i smart-auth-validator&lt;/code&gt;&lt;br&gt;
Hey there! You know how developers sometimes struggle with those tricky authentication forms when working on backends? It can get pretty complicated with all the conditions and making sure data is secure. Well, I just published a new package called &lt;br&gt;
"smart-auth-validator"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This makes backend form validation easy for Node.js. It has type-safe rules. You won’t need to deal with regex or safety for your Fastify and Express backend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Benefits
&lt;/h2&gt;

&lt;p&gt;This library eliminates repetitive validation code through built-in checks for emails, passwords, names, and phones. Developers gain structured error responses like "REQUIRED", "MIN_LENGTH" or "WEAK_PASSWORD," , etc.. speeding up API builds. Its lightweight design fits modern stacks system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Setup and Usage
&lt;/h2&gt;

&lt;p&gt;Install via npm for instant compatibility with your Node.js stack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i smart-auth-validator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Validate any form with a simple schema object—pick only what you need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { validate } from "smart-auth-validator";

const result = validate(
  { name: true, email: true, password: true },
  req.body
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Success returns clean data; failures give precise, field-specific errors for better UX. Extend with custom rules if needed, keeping your codebase lean&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Benefits
&lt;/h2&gt;

&lt;p&gt;Speed: No more debugging regex—prebuilt rules work out-of-the-box for registration, login, or profile forms.&lt;/p&gt;

&lt;p&gt;Security: Enforces strong password standards and valid formats, reducing breach risks.&lt;/p&gt;

&lt;p&gt;Scalability: Lightweight footprint scales with Fastify/Express apps, from startups to enterprise.&lt;/p&gt;

&lt;p&gt;Developers report fewer bugs and faster iterations, as the library's pattern recognition handles variations automatically. Positive framing: Transform validation from chore to confidence booster.&lt;br&gt;
​&lt;/p&gt;

&lt;p&gt;Ready to ditch repetitive code? Check it out on npm and level up your backend: &lt;a href="https://www.npmjs.com/package/smart-auth-validator" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/smart-auth-validator&lt;/a&gt;. Your future self will thank you.&lt;/p&gt;

</description>
      <category>npm</category>
      <category>node</category>
      <category>security</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
