<?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: Sultan Akhter</title>
    <description>The latest articles on DEV Community by Sultan Akhter (@i-sultan0).</description>
    <link>https://dev.to/i-sultan0</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%2F699773%2F3334d286-523a-4c88-8222-7bf2201f71af.png</url>
      <title>DEV Community: Sultan Akhter</title>
      <link>https://dev.to/i-sultan0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/i-sultan0"/>
    <language>en</language>
    <item>
      <title>Null vs. Undefined in JavaScript: The Ultimate Showdown</title>
      <dc:creator>Sultan Akhter</dc:creator>
      <pubDate>Tue, 06 Aug 2024 01:01:21 +0000</pubDate>
      <link>https://dev.to/i-sultan0/null-vs-undefined-in-javascript-the-ultimate-showdown-2h7f</link>
      <guid>https://dev.to/i-sultan0/null-vs-undefined-in-javascript-the-ultimate-showdown-2h7f</guid>
      <description>&lt;p&gt;Welcome to the world of JavaScript, where null and undefined are the dynamic duo of nothingness! These two siblings might seem similar, but they have their own quirks and personalities. Let’s dive into this exciting world of JavaScript to uncover the differences between null and undefined, and see some fun examples along the way!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Basics: What Are Null and Undefined?
&lt;/h2&gt;

&lt;p&gt;In JavaScript, both null and undefined represent the absence of value, but they are not the same. Think of undefined as a mischievous imp who forgets to show up, while null is a cool cat who intentionally decides to sit out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Undefined:&lt;/strong&gt; This is JavaScript’s default way of saying, “Oops, we forgot to give this a value.” It happens when you declare a variable but don’t assign anything to it.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Null:&lt;/strong&gt; This is used by developers to say, “This should have no value.” It’s an intentional absence of any value.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  The Quirky Differences
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Type Check:
&lt;/h3&gt;

&lt;p&gt;The typeof undefined returns 'undefined' but typeof null returns 'object'. Yes, it’s weird and it’s a known bug!&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Equality Check:
&lt;/h3&gt;

&lt;p&gt;null == undefined returns true. They’re considered loosely equal.&lt;br&gt;
null === undefined returns false. Strict equality shows their differences.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Use Cases:
&lt;/h2&gt;

&lt;p&gt;Use undefined for uninitialized variables, missing parameters, or default returns.&lt;/p&gt;

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

&lt;p&gt;Use null when you want to explicitly state that a variable should be empty.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;undefined:&lt;/strong&gt; Default for uninitialized variables.&lt;br&gt;
&lt;strong&gt;null:&lt;/strong&gt; Explicitly assigned to signify no value.&lt;br&gt;
&lt;strong&gt;Type Check:&lt;/strong&gt; typeof undefined is "undefined", typeof null is "object".&lt;br&gt;
&lt;strong&gt;Equality Check:&lt;/strong&gt; null == undefined is true, null === undefined is false.&lt;br&gt;
&lt;strong&gt;Use Cases:&lt;/strong&gt; Use undefined for missing values; use null for intentional emptiness.&lt;br&gt;
Now, armed with this knowledge, you’re ready to navigate the fascinating world of JavaScript with null and undefined by your side. Happy coding!&lt;/p&gt;

&lt;p&gt;If you want to learn/revise about the basics of Javascript, &lt;a href="https://dev.to/i-sultan0"&gt;follow me&lt;/a&gt; and checkout some other articles related to the &lt;a href="https://dev.to/i-sultan0/understanding-javascript-closures-without-breaking-a-sweat-1d6d"&gt;basic concept of Javascript&lt;/a&gt;.&lt;br&gt;
Follow me on &lt;a href="https://www.linkedin.com/in/sultan-akhter/" rel="noopener noreferrer"&gt;linked in&lt;/a&gt; for daily Js quiz questions.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Understanding Javascript Closures (Without Breaking a Sweat!)</title>
      <dc:creator>Sultan Akhter</dc:creator>
      <pubDate>Sun, 21 Jul 2024 20:15:34 +0000</pubDate>
      <link>https://dev.to/i-sultan0/understanding-javascript-closures-without-breaking-a-sweat-1d6d</link>
      <guid>https://dev.to/i-sultan0/understanding-javascript-closures-without-breaking-a-sweat-1d6d</guid>
      <description>&lt;p&gt;JavaScript is full of fascinating concepts, but few are as enchanting (and sometimes perplexing) as closures. If you’ve ever scratched your head wondering what closures are, you're in the right place. By the end of this two-minute read, you'll be able to dazzle your friends with your newfound knowledge. Ready? Let’s dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  What Exactly is a Closure?
&lt;/h2&gt;

&lt;p&gt;In JavaScript, a closure is like a backpack. Imagine a function packing its variables and taking them along wherever it goes, even after the outer function has finished executing. This ability to remember and access its lexical scope is what makes a closure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Should You Care About Closures?
&lt;/h2&gt;

&lt;p&gt;Closures are everywhere in JavaScript. They are crucial for creating powerful and efficient code, especially when dealing with asynchronous operations, callbacks, and functional programming. Mastering closures can elevate your JavaScript skills from “meh” to “wow!”&lt;/p&gt;

&lt;h2&gt;
  
  
  The Closure Magic Show
&lt;/h2&gt;

&lt;p&gt;Let’s break it down with a simple example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Frk556qclvocuoh6wmy88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Frk556qclvocuoh6wmy88.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Here’s what’s happening:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Outer Function: 'outerFunction' defines a variable 'outerVariable' and an 'innerFunction'.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inner Function: 'innerFunction' has access to 'outerVariable' even after 'outerFunction' has executed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Closure in Action: When 'myClosure' is called, it remembers the environment in which it was created, logging "I’m the outer variable!".&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Common Uses for Closures
&lt;/h2&gt;

&lt;h2&gt;
  
  
  1. Data Privacy:
&lt;/h2&gt;

&lt;p&gt;Closures can help keep variables private and protect them from the outside world. Think of them as JavaScript’s version of a “Do Not Disturb” sign.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F28qv4tsd4osft9y2remb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F28qv4tsd4osft9y2remb.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Creating Factories:
&lt;/h2&gt;

&lt;p&gt;Closures are perfect for factory functions, where you need to create multiple instances of a function with their own private state.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fm468ubzrgdza3xb6llex.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fm468ubzrgdza3xb6llex.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Closures might sound like magic, but they are a fundamental part of JavaScript that can make your code more efficient and powerful. Remember, a closure is simply a function bundled together with its surrounding state (the lexical environment). So, next time you see a closure in action, give yourself a pat on the back – you’ve just witnessed some JavaScript wizardry!&lt;/p&gt;

&lt;p&gt;Happy coding, and may your closures always be tight!&lt;/p&gt;

&lt;p&gt;If you want to learn/revise about the basics of Javascript, &lt;a href="https://dev.to/i-sultan0"&gt;follow me &lt;/a&gt;and checkout some other articles related to the &lt;a href="https://dev.to/i-sultan0/confused-by-var-let-and-const-lets-clear-the-mess-4kn7"&gt;basic concept of Javascript&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Confused by var, let, and const? Let's Clear the Mess</title>
      <dc:creator>Sultan Akhter</dc:creator>
      <pubDate>Tue, 16 Jul 2024 22:38:17 +0000</pubDate>
      <link>https://dev.to/i-sultan0/confused-by-var-let-and-const-lets-clear-the-mess-4kn7</link>
      <guid>https://dev.to/i-sultan0/confused-by-var-let-and-const-lets-clear-the-mess-4kn7</guid>
      <description>&lt;p&gt;Ah, JavaScript variables! If you’ve ever found yourself scratching your head over the differences between var, let, and const, you’re not alone. Understanding these three can feel like trying to navigate a maze. But fear not, dear coder! I am here to clarify the confusion.&lt;/p&gt;

&lt;h1&gt;
  
  
  Basic Concept : Assigning and Redeclaration of Variable
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Let's start with 'Var' - The Old Guard of JS
&lt;/h2&gt;

&lt;p&gt;The variable associated with 'var' keyword can be reassign and redeclared.&lt;br&gt;
&lt;a href="https://media.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%2Fjc63a1o6iifkilfz0dim.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fjc63a1o6iifkilfz0dim.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  'Let' - The Modern contender
&lt;/h2&gt;

&lt;p&gt;The variable associated with 'let' can be reassign but cannot be redeclared.&lt;br&gt;
&lt;a href="https://media.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%2Fv80fqv218yqeldi5gchp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fv80fqv218yqeldi5gchp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  'Const' - The Immutable Force
&lt;/h2&gt;

&lt;p&gt;The variable associated with 'const' can neither be reassign not redeclared.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fkijfxggfqdo9ifxs4bml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fkijfxggfqdo9ifxs4bml.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are a beginner and want to know about the bare minimum about variables, then this STOP is for you. Below we will discuss some advance concepts related to variables which will come in handy like Scoping and Hoisting .&lt;/p&gt;

&lt;h2&gt;
  
  
  Scoping - Accessibility of variables within specific parts of code.
&lt;/h2&gt;

&lt;p&gt;Where 'var' has Function Scope but 'let' and 'const' are Block Scope. It means 'var' can be accessed throughout the function even in blocks (if,else etc..) And 'let' and 'const' can be accessed inside its own Block.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fn781pjbpfsv38nkzlhtq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fn781pjbpfsv38nkzlhtq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hoisting - In simple words, it means using variables without declaring them is called Hoisting.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fqz7qlvydrknx4hb2xg6x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fqz7qlvydrknx4hb2xg6x.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;'var' declaration is hoisted and initialized as 'undefined', you can use the variable before its declartion but its value will be undefined.&lt;br&gt;
'let' and 'const' declaration is hoisted but not initialized, you cannot use the variable before its declaration, attempting to do so will result in 'reference error'.&lt;/p&gt;

&lt;p&gt;Thankyou for reading, I am starting my journey of posting, related to Web Development. Do like and share to support me. &lt;br&gt;
If you have any question regarding the topic or the info shared in the blog, please leave a comment.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
