<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by  Anamika Deb on Medium]]></title>
        <description><![CDATA[Stories by  Anamika Deb on Medium]]></description>
        <link>https://medium.com/@debanamika?source=rss-8451c424be69------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uR5vYCQWkXnmd24P2ac3IA.jpeg</url>
            <title>Stories by  Anamika Deb on Medium</title>
            <link>https://medium.com/@debanamika?source=rss-8451c424be69------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:25:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@debanamika/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ “not defined” or “undefined”: Demystifying JavaScript’s Hidden Errors ]]></title>
            <link>https://medium.com/@debanamika/undefined-or-not-defined-demystifying-javascripts-hidden-errors-90a7f86a90c9?source=rss-8451c424be69------2</link>
            <guid isPermaLink="false">https://medium.com/p/90a7f86a90c9</guid>
            <category><![CDATA[undefined]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[not-defined]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[ Anamika Deb]]></dc:creator>
            <pubDate>Mon, 02 Sep 2024 12:44:12 GMT</pubDate>
            <atom:updated>2024-09-02T12:46:12.906Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jfM_yh1EHpyU_WBta8P9rA.png" /></figure><p>Ever stumbled upon JavaScript errors and wondered what undefined and not defined really mean? Discover the key differences between these common issues, understand their causes, and learn how to handle them effectively with this comprehensive guide.</p><h3>1. What Does undefined Mean?</h3><ul><li>A variable that has been declared but hasn’t been assigned a value.</li><li>Returns the undefined value when accessed.</li></ul><p><strong>When Does It Occur?</strong></p><ul><li>Variable Declaration Without Initialization</li><li>Function Without a Return Statement.</li><li>Object Property Not Set.</li></ul><p>Example</p><pre>let x;<br>console.log(x); // Output: undefined</pre><pre>function greet() {<br>  console.log(&#39;Hello, World!&#39;);<br>}<br><br>let result = greet();<br>console.log(result); // Output: undefined</pre><pre><br>let person = { name: &#39;Alice&#39; };<br>console.log(person.age); // Output: undefined</pre><blockquote><strong>Key Points:</strong></blockquote><ul><li>undefined is a type of its own, meaning that typeof undefined returns &quot;undefined&quot;.</li><li>It is automatically assigned by JavaScript to variables and properties that haven’t been initialized.</li></ul><h3>2. What Does not defined Mean?</h3><ul><li>A variable that hasn’t been declared at all.</li><li>Accessing a “not defined” variable results in a ReferenceError.</li></ul><p><strong>When Does It Occur?</strong></p><ul><li>Accessing an Uninitialized Variable.</li><li>Misspelling Variable Names.</li></ul><p>Example</p><pre>let car = { brand: &#39;Toyota&#39; };<br>console.log(y); // ReferenceError: y is not defined</pre><blockquote><strong>Key Points:</strong></blockquote><ul><li>not defined errors occur due to a missing declaration, and the ReferenceError thrown helps you identify the issue.</li><li>It’s important to ensure that variables are declared before use to avoid these errors.</li></ul><h3>3. Key Differences and Practical Implications</h3><p><strong>undefined vs </strong><strong>not defined:</strong></p><ul><li><strong>Scope:</strong> undefined is a value that a variable can hold, indicating no value or an uninitialized state. not defined is an error indicating that a variable or property does not exist in the current scope.</li><li><strong>Error Handling:</strong> undefined does not throw an error; it is a normal part of JavaScript’s type system. On the other hand, accessing a not defined variable results in a ReferenceError which needs to be fixed by declaring the variable.</li></ul><h3><strong>Pro Tips:</strong></h3><ul><li><strong>Declare Variables Before Use:</strong> Ensure that variables are declared before accessing them to prevent ReferenceError issues.</li><li><strong>Avoid using </strong><strong>undefined as a default value:</strong> Instead, use null or a meaningful default.</li><li><strong>Check for both </strong><strong>undefined and </strong><strong>null when necessary:</strong> Use the typeof operator or a combination of strict equality checks.</li><li><strong>Use Strict Mode:</strong> Consider using JavaScript’s strict mode (&#39;use strict&#39;;) to catch undeclared variables early and avoid common mistakes.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90a7f86a90c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Understanding Data Types and Variables in JavaScript: A Comprehensive Guide ]]></title>
            <link>https://medium.com/@debanamika/understanding-data-types-and-variables-in-javascript-a-comprehensive-guide-6e46a4156353?source=rss-8451c424be69------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e46a4156353</guid>
            <category><![CDATA[javascript-data-type]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[javascript-basics]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[ Anamika Deb]]></dc:creator>
            <pubDate>Mon, 02 Sep 2024 12:00:03 GMT</pubDate>
            <atom:updated>2024-09-02T12:57:14.700Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3tgEyQNzSt_p4ICY" /><figcaption>Photo by <a href="https://unsplash.com/@growtika?utm_source=medium&amp;utm_medium=referral">Growtika</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>JavaScript is a dynamically typed language, meaning you don’t need to specify data types when declaring variables. However, understanding JavaScript’s data types and how variables work is crucial for writing effective and bug-free code. In this guide, we’ll explore the different data types JavaScript uses, how to declare and manage variables, and best practices for handling data in your applications.</p><h3>1. JavaScript Data Types: The Basics</h3><p>JavaScript’s data types fall into two categories: <strong>primitive types</strong> and <strong>object types</strong>. Let’s break them down:</p><h4>Primitive Data Types</h4><p>Primitive data types are immutable and are compared by their value. They include:</p><blockquote><strong>String</strong></blockquote><ul><li>Represents a sequence of characters.</li><li>Can be enclosed in single quotes (&#39;), double quotes (&quot;), or backticks (`).</li></ul><p><strong>Example:</strong></p><pre>let greeting = &#39;Hello, World!&#39;;<br>let name = &quot;Anamika&quot;;<br>let templateLiteral = `Hello, ${name}!`;</pre><blockquote><strong>Number</strong></blockquote><ul><li>Represents both integer and floating-point numbers.</li><li>JavaScript does not differentiate between integer and float.</li></ul><p><strong>Example:</strong></p><pre>let age = 25;<br>let price = 19.99;</pre><blockquote><strong>BigInt</strong></blockquote><ul><li>Represents integers with arbitrary precision.</li><li>Useful for very large integers.</li></ul><p><strong>Example:</strong></p><pre>let bigNumber = 1234567890123456789012345678901234567890n;</pre><blockquote><strong>Boolean</strong></blockquote><ul><li>Represents a logical entity with two values: true or false.</li></ul><p><strong>Example:</strong></p><pre>let isJavaScriptFun = true;<br>let isCoffeeGood = false;</pre><blockquote><strong>Undefined</strong></blockquote><ul><li>Represents a variable that has been declared but not yet assigned a value.</li></ul><p><strong>Example:</strong></p><pre>let notAssigned;<br>console.log(notAssigned); // Output: undefined</pre><p><em>** For a deeper dive into the differences between </em><em>undefined and </em><em>not defined, and to understand how to handle these concepts in JavaScript, check out my detailed post here: </em><a href="https://medium.com/@debanamika/undefined-or-not-defined-demystifying-javascripts-hidden-errors-90a7f86a90c9"><strong><em>undefined vs </em></strong></a><a href="https://medium.com/@debanamika/undefined-or-not-defined-demystifying-javascripts-hidden-errors-90a7f86a90c9"><strong><em>not defined: Demystifying JavaScript’s Hidden Errors.</em></strong></a>**</p><blockquote><strong>Null</strong></blockquote><ul><li>Represents the intentional absence of any object value. It’s often used to indicate a variable with no value.</li></ul><p><strong>Example:</strong></p><pre>let emptyValue = null;</pre><blockquote><strong>Symbol (ES6)</strong></blockquote><ul><li>Represents a unique and immutable value primarily used as object property keys.</li></ul><p><strong>Example:</strong></p><pre>const uniqueId = Symbol(&#39;id&#39;);</pre><h4>Object Data Types</h4><p>Objects are more complex data structures and are compared by reference. They include:</p><blockquote><strong>Object</strong></blockquote><ul><li>A collection of key-value pairs.</li></ul><p><strong>Example:</strong></p><pre>let person = {<br>  name: &#39;Anamika&#39;,<br>  age: 23,<br>  isMarried: false<br>};</pre><blockquote><strong>Array</strong></blockquote><ul><li>An ordered list of values.</li></ul><pre>let colors = [&#39;red&#39;, &#39;green&#39;, &#39;blue&#39;];</pre><h3>2. Declaring and Managing Variables</h3><p>To store data in JavaScript, we use variables. Variables are containers for values. You can declare variables using the var, let, or const keywords.</p><blockquote><strong>var: </strong>The traditional way to declare variables, but it has some limitations regarding variable scope.</blockquote><ul><li><strong>Scope:</strong> Function-scoped or globally scoped if declared outside of a function.</li><li><strong>Hoisting:</strong> Variables declared with var are hoisted to the top of their scope and initialized with undefined.</li></ul><pre>var name = &#39;Anamika&#39;;<br>console.log(name); // Output: Anamika</pre><blockquote><strong>let:</strong> A more modern way to declare variables, offering block-scoped behavior and avoiding hoisting issues.</blockquote><ul><li><strong>Scope:</strong> Block-scoped, meaning it’s only accessible within the block it’s defined.</li><li><strong>Hoisting:</strong> Variables declared with let are hoisted but not initialized, leading to a &quot;Temporal Dead Zone&quot; until the declaration is encountered.</li></ul><pre>let age = 25;<br>if (age &gt; 20) {<br>  let age = 30; // Different variable<br>  console.log(age); // Output: 30<br>}<br>console.log(age); // Output: 25</pre><blockquote><strong>const:</strong> Declares a constant value that cannot be reassigned.</blockquote><ul><li><strong>Scope:</strong> Block-scoped.</li><li><strong>Hoisting:</strong> Similar to let, const declarations are hoisted but not initialized.</li><li><strong>Immutability:</strong> Variables declared with const cannot be reassigned, though the contents of objects and arrays can still be modified.</li></ul><pre>const pi = 3.14;<br>console.log(pi); // Output: 3.14<br>pi = 3.14159; // Error: Assignment to constant variable.</pre><h3>3. Pro Tips</h3><ul><li>JavaScript is a dynamically typed language, meaning you don’t need to explicitly specify the data type of a variable when declaring it.</li><li>The data type of a variable can change during runtime.</li><li>Use<strong> </strong><strong>let </strong>and<strong> </strong><strong>const </strong>over<strong> </strong><strong>var</strong> to avoid scope issues and ensure clearer code.</li><li>Prefer<strong> </strong><strong>const</strong> when you don’t plan to reassign the variable to enforce immutability and reduce bugs.</li><li>Use<strong> descriptive names</strong> for variables to make code more readable and maintainable.</li><li>Avoid<strong> global variables</strong> to prevent potential conflicts and unintended side effects.</li></ul><h3>Conclusion</h3><p>Understanding JavaScript’s data types and variable management is fundamental to writing clean, effective code. By grasping these concepts, you’ll be better equipped to handle various programming challenges and avoid common pitfalls. Stay tuned for more posts in our series where we delve deeper into advanced JavaScript topics and best practices!</p><p>Feel free to leave comments or questions below — happy coding! 🚀</p><p><strong>#JavaScript #DataTypes #Variables #Coding #WebDevelopment #Programming</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e46a4156353" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>