<?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: Ramya Sri M</title>
    <description>The latest articles on DEV Community by Ramya Sri M (@ramya_srim).</description>
    <link>https://dev.to/ramya_srim</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%2F2100949%2F9fc4eaa1-7fa7-468d-8772-07aa2aeccbac.png</url>
      <title>DEV Community: Ramya Sri M</title>
      <link>https://dev.to/ramya_srim</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ramya_srim"/>
    <language>en</language>
    <item>
      <title>🌟 Dream-to-Reality Planner: Where 🎨 imagination meets 🚀 execution</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Sun, 14 Sep 2025 10:41:16 +0000</pubDate>
      <link>https://dev.to/ramya_srim/dream-to-reality-planner-where-imagination-meets-execution-370g</link>
      <guid>https://dev.to/ramya_srim/dream-to-reality-planner-where-imagination-meets-execution-370g</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/google-ai-studio-2025-09-03"&gt;Google AI Studio Multimodal Challenge&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;This is a Dream-to-Reality AI Planner ✨ — a motivational and personalized goal-setting application.&lt;/p&gt;

&lt;p&gt;Users provide a dream or goal — anything from “💻 learn to code a website” to “🏃 run a marathon” — and the AI generates a complete, actionable roadmap to achieve it.&lt;/p&gt;

&lt;p&gt;Unlike a static checklist, the app provides a rich, interactive plan 📋 filled with milestones, sub-steps, resources, and motivational boosts to keep users engaged on their journey.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem It Solves
&lt;/h2&gt;

&lt;p&gt;Many people struggle to turn ambitious goals into realistic, step-by-step action plans. They either feel 😣 overwhelmed or lose 💪 motivation along the way.&lt;/p&gt;

&lt;p&gt;This project solves that by giving them a structured roadmap, interactive tracking tools 📊, and continuous motivation 🔥 — all generated instantly with the Gemini API.&lt;/p&gt;

&lt;h2&gt;
  
  
  The User’s Journey
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Input&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The user sees a clean, simple form.&lt;/li&gt;
&lt;li&gt;They type in their dream or goal.&lt;/li&gt;
&lt;li&gt;Optionally, they upload an inspiration image 🖼️ to personalize the plan.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Generation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The dream + image are sent to Gemini.&lt;/li&gt;
&lt;li&gt;A loading screen appears with a friendly message: “Crafting your roadmap… 🛠️”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Roadmap Output&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The AI generates a structured roadmap, which includes:&lt;/li&gt;
&lt;li&gt;🎖️ Milestones (big phases of the goal).&lt;/li&gt;
&lt;li&gt;✅ Substeps (smaller, actionable tasks).&lt;/li&gt;
&lt;li&gt;🔗 Resources &amp;amp; Motivation (trusted links + motivational quotes).&lt;/li&gt;
&lt;li&gt;🎬 Bonus Content (poster ideas &amp;amp; YouTube video suggestions).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Interaction &amp;amp; Persistence&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Users tick off substeps, and progress bars update in real-time.&lt;/li&gt;
&lt;li&gt;🎉 Completing a milestone triggers a celebration animation.&lt;/li&gt;
&lt;li&gt;✏️ Users can edit milestones (title, motivation, duration, resources).&lt;/li&gt;
&lt;li&gt;💾 Plans are saved in a personal dashboard using local storage.&lt;/li&gt;
&lt;li&gt;🔥 A streak counter motivates users by rewarding daily progress.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;✨Turn your dream into reality—try the live demo here : &lt;a href="https://dream-to-reality-planner-ai-1073554890557.us-west1.run.app" rel="noopener noreferrer"&gt;Your Demo Link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s a project screenshot showing the AI turning dreams into actionable plans🚀:&lt;/strong&gt;&lt;br&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%2Fdjj4trgy18g1heat5aym.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%2Fdjj4trgy18g1heat5aym.png" alt="Dream Input Form"&gt;&lt;/a&gt;&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%2Fg7j9djp1xrp2rtfnjdxt.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%2Fg7j9djp1xrp2rtfnjdxt.png" alt="Upload an Image"&gt;&lt;/a&gt;&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%2Fxn5r6a7d6h6psbdsmkrd.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%2Fxn5r6a7d6h6psbdsmkrd.png" alt="Loading Page"&gt;&lt;/a&gt;&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%2Fcwd2wnzm888zjvlp8kj0.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%2Fcwd2wnzm888zjvlp8kj0.png" alt="Roadmap"&gt;&lt;/a&gt;&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%2Fizmwll5qly81h12zo838.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%2Fizmwll5qly81h12zo838.png" alt="Substeps"&gt;&lt;/a&gt;&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%2Flw56o7l5ht1tyicctxif.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%2Flw56o7l5ht1tyicctxif.png" alt="Congratulation Message"&gt;&lt;/a&gt;&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%2Fae2f8aksjlvsht2cgld1.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%2Fae2f8aksjlvsht2cgld1.png" alt="Dashboard"&gt;&lt;/a&gt;&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%2F2pspocz0az7f5t7u2ydy.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%2F2pspocz0az7f5t7u2ydy.png" alt="Motivational&amp;amp;poster"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Used Google AI Studio
&lt;/h2&gt;

&lt;p&gt;Google AI Studio played the role of a true co-creator in this project. From designing features and refining the UI to structuring the roadmap and logic, every part of the app was shaped through iterative collaboration with AI. What started as an idea quickly became a polished, interactive product powered by Gemini.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multimodal Features
&lt;/h2&gt;

&lt;p&gt;One of the most powerful aspects of this project is its multimodal input, powered by Gemini-2.5-Flash. Unlike traditional text-only planners, it processes both your text and images to create a personalized, visually inspired roadmap.&lt;/p&gt;

&lt;p&gt;Why Gemini-2.5-Flash?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🖼️ Multimodal Input: Combines your goal description and inspiration photos.&lt;/li&gt;
&lt;li&gt;⚡ Speed &amp;amp; Efficiency: Instant roadmap generation.&lt;/li&gt;
&lt;li&gt;🧩 Structured Output: Returns clean JSON ready for the React UI—no messy parsing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example in Action:&lt;br&gt;
Dream: “Write my first novel”&lt;br&gt;
Image Input: Cozy writing desk or typewriter photo&lt;br&gt;
AI Output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📅 Daily writing goals (“500 words/day”)&lt;/li&gt;
&lt;li&gt;🖋 Creative writing prompts&lt;/li&gt;
&lt;li&gt;📚 Storytelling techniques &amp;amp; structure guides&lt;/li&gt;
&lt;li&gt;🎤 Motivational resources&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;The Dream-to-Reality Planner turns raw ambition into a guided, interactive journey. By combining Gemini’s multimodal capabilities with a modern React frontend, it helps users move from dreaming to doing.&lt;/p&gt;

&lt;p&gt;✨ Try it out. Share your dream. Start your journey.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>googleaichallenge</category>
      <category>ai</category>
      <category>gemini</category>
    </item>
    <item>
      <title>Closures in JS🤯</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Mon, 16 Dec 2024 08:42:44 +0000</pubDate>
      <link>https://dev.to/ramya_srim/closures-in-js-35e</link>
      <guid>https://dev.to/ramya_srim/closures-in-js-35e</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Closures&lt;/u&gt;&lt;/strong&gt;🔥&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A function, bundled together with its lexical scope, forms a closure.&lt;/li&gt;
&lt;li&gt;A closure provides access to an outer function's scope from an inner function.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function x() {
   var a = 7;
   function y() {
       console.log(a) ;
   }
  y() ;
}
x() ;  
// 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this program, when y() tries to run, it looks for 'a' in its local memory. Since it does not find it there, it accesses its lexical parent, x.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function x() {
   var a = 7;
   function y() {
       console.log(a) ;
   }
  return  y;
}
var z = x() ;
console.log(z) ; //ƒ y() {console.log(a); }
z() ; // 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above program, the console.log statement returns the function y() (i.e., function y() { console.log(a); }). When 'y' is returned, the function is returned, and the entire closure (the function y along with its lexical scope) is returned and assigned to 'z'. As a result, when 'z' is used elsewhere in the program, it still retains access to the variable 'a' inside x(). Even though x() no longer exists, the 'y' function remembers its lexical scope, allowing z() to output 7.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Whenever a function is returned, even if it vanishes from the execution context, it still retains the reference it was pointing to. It does not return just the function alone but the entire closure.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function z() {
    var b = 100;
    function x() {
        var a=7;
        function y(){
            console.log(a,b);
        }
        y();
    }
    x();
}
z(); 
&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%2Frkguldhvgy9p54sskf1q.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%2Frkguldhvgy9p54sskf1q.png" alt="Closures" width="800" height="787"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above image, 'y' forms a closure with the scope of 'x' and the scope of 'z'.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Credits to Akshay Saini.&lt;/em&gt;&lt;/strong&gt; [(&lt;a href="https://youtu.be/qikxEIxsXco?si=sRe_4k5swSbnr50T)" rel="noopener noreferrer"&gt;https://youtu.be/qikxEIxsXco?si=sRe_4k5swSbnr50T)&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Shortest JS Program, Window &amp; this keyword 🔥</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Wed, 27 Nov 2024 17:22:39 +0000</pubDate>
      <link>https://dev.to/ramya_srim/shortest-js-program-window-this-keyword-1da0</link>
      <guid>https://dev.to/ramya_srim/shortest-js-program-window-this-keyword-1da0</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Shortest JS Program&lt;/u&gt;&lt;/strong&gt; 🤔&lt;/p&gt;

&lt;p&gt;The shortest program in JavaScript is an empty file. Although the file is empty and there is nothing to execute, the JavaScript engine still performs several tasks behind the scenes. If we run the shortest JavaScript program (i.e., an empty file), the engine creates a global execution context and allocates memory space. Even with nothing to set up, it is still doing its job.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;window &amp;amp; this keyword&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The JavaScript engine creates something known as the window object. The window object is the global object that is created alongside the global execution context. It contains functions and variables, which are attached to the global object (i.e., window). All JavaScript engines are responsible for creating the global object. In the case of browsers, this global object is the window.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Along with the execution context, the JavaScript engine also creates the 'this' keyword. At the global level, this points to the window object in the case of a browser.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;this === window&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = 11;
console.log(window.a); //11
console.log(a);        //11 (If we don't specify window (window.a), it automatically assumes that we are referring to the global space.)
console.log(this.a);   //11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These variables and functions are attached to the global object (i.e., window). If we create a variable in the global scope, it gets attached to the global object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Credits to Akshay Saini.&lt;/em&gt;&lt;/strong&gt; [(&lt;a href="https://youtu.be/QCRpVw2KXf8?si=5YAjXNQ0wxvCo96Z)" rel="noopener noreferrer"&gt;https://youtu.be/QCRpVw2KXf8?si=5YAjXNQ0wxvCo96Z)&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Callback Function 🔥</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Tue, 26 Nov 2024 18:27:18 +0000</pubDate>
      <link>https://dev.to/ramya_srim/callback-function-1ljk</link>
      <guid>https://dev.to/ramya_srim/callback-function-1ljk</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Callback Function&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Functions are first-class citizens, meaning take a function and pass into another function.It provides access to the entire asynchronous world in a synchronous world.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function x(y){

}
x(function y(){

});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take a function y and pass it into another function x. Here, y is a callback function. This allows function x to call function y.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setTimeout(function () {
    console.log("Timer");
}, 8000)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function passed as the first parameter to setTimeout is the callback function, and the second parameter is the timer.&lt;/p&gt;

&lt;p&gt;JavaScript is a synchronous and single-threaded language. However, with callbacks, we can perform asynchronous operations in JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setTimeout(function () {
    console.log("timer");
  }, 6000);
  function x(y) {
    console.log("x");
    y();
  }
  x(function y() {
    console.log("y");
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Look at the above code. Initially, x and y are present in the call stack, and then the call stack becomes empty. setTimeout will take this callback function and store it in a separate space, attaching a timer to it(Eg:6 seconds). After 6 seconds, the timer will be added to the call stack.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If x() takes 20 seconds to run, JavaScript must wait for it to finish. JavaScript has only one call stack, which is also referred to as the main thread.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Everything is executed through the call stack.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Blocking The Main Thread&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Any operation that blocks the call stack is referred to as blocking the main thread.&lt;/li&gt;
&lt;li&gt;Never block the main thread.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Always try to use asynchronous operations for tasks that take time, such as setTimeout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Credits to Akshay Saini.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Demystifying Function Statements, Expressions, and more in JavaScript🔥</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Mon, 25 Nov 2024 18:29:44 +0000</pubDate>
      <link>https://dev.to/ramya_srim/functions-3a60</link>
      <guid>https://dev.to/ramya_srim/functions-3a60</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Function Statement&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Function Statement is also known as a Function Declaration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function x(){
  console.log("x called");
}
x(); // x called
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way of creating a function, using the function keyword followed by the function name and its body, is known as a function statement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Function Expression&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Assigning a function to a variable makes the function act like a value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var y = function (){
  console.log("y called");
}
y();// y called
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is known as Function Expression.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function x(){
  console.log("x called");
}

var y = function (){
  console.log("y called");
}
x(); //x called
y(); // y called
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x(); 
y();

function x(){
  console.log("x called");
}

var y = function (){
  console.log("y called");
}

//x called
//TypeError: y is not a function

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

&lt;/div&gt;



&lt;p&gt;The main difference between a function statement and a function expression is hoisting.&lt;/p&gt;

&lt;p&gt;Look at the code above.In the hoisting phase, during the memory creation phase, JavaScript creates memory for a function (e.g., x(): {...}). However, in the case of a function expression, y is treated like a another variable and is initially assigned undefined. It can only be called after it has been defined in the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Anonymous Function&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A function without a name is known as an anonymous function. According to the ECMAScript specification, a function statement should always have a name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function () {

} //SyntaxError: Function statements require a function name.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anonymous functions are used in places where functions are used as values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Named Function Expression&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is the same as a function expression, but we must provide a function name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var y = function greet(){
  console.log("y called");
}
y(); //y called
greet(); //ReferenceError: greet is not defined.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;&lt;strong&gt;First Class Function&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;First Class Function is also known as First class citizens. The ability of functions to be used as values, passed as arguments to other functions, and returned from functions is known as First Class Function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var y = function(param1){
  return function greet(){

  }
}
console.log(y());

//ƒ greet(){

  }
--------------------------------------------------------------------

var y = function(param1) {
  console.log(param1);
}
function greet(){
}
y(greet);

//ƒ greet(){
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Credits to Akshay Saini.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Block Scope &amp; Shadowing in JS🤯</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Sun, 24 Nov 2024 17:31:07 +0000</pubDate>
      <link>https://dev.to/ramya_srim/block-scope-shadowing-in-js-24df</link>
      <guid>https://dev.to/ramya_srim/block-scope-shadowing-in-js-24df</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Block&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A block, also known as a compound statement, is defined by curly braces {}. It groups multiple JavaScript statements together into a single unit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  //compound statement
  var x = 60;
  console.log(x);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Block Scope&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Block scope means that all variables and functions declared inside a block {} are accessible only within that block.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  var x = 36;
  let y = 27;
  const z = 78;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let and const have separate memory and are block-scoped, whereas var is function-scoped or globally scoped.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  var x = 36;
  let y = 27;
  const z = 78;
  console.log(x); //36
  console.log(y); //27
  console.log(z); //78
};
console.log(x); //36
console.log(y); //ReferenceError: y is not defined
console.log(z);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can access var outside the block because it has global or function scope. However, let and const cannot be accessed outside the block because they are block-scoped.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Shadowing&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If we have a variable with the same name both outside and inside a block, the variable inside the block shadows the one outside.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var x = 57;
{
  var x = 36;
  let y = 27;
  const z = 78;
  console.log(x); //36
  console.log(y); //27
  console.log(z); //78
};
console.log(x); //36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have two variables with the same name (var x). The variable var x = 36 shadows the variable var x = 57. Both variables share the same memory space. As a result, the value of x is first assigned 57 and then modified to 36, since they both point to the same memory location (They are in global scope).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let y = 51;
{
  var x = 36;
  let y = 27;
  const z = 78;
  console.log(x); //36
  console.log(y); //27
  console.log(z); //78
};
console.log(y); //51
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have two variables with the same name (let y). The variable let y = 27 shadows the variable let y = 51. This code has three scopes: global scope, block scope, and script scope (let and const have separate memory spaces). The variable let y = 27 is block-scoped, while let y = 51 belongs to the script scope. As a result, console.log inside the block outputs 27, and outside the block, it outputs 51&lt;/p&gt;

&lt;p&gt;The same applies to const as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const z = 21;
{
  var x = 36;
  let y = 27;
  const z = 78;
  console.log(x); // 36
  console.log(y); //27
  console.log(z); //78
};
console.log(z); //21
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;br&gt;
Illegal Shadowing&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x = 4;
{
  var x = 7;
};// SyntaxError: Identifier 'x' has already been declared.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We cannot shadow let using var. This is illegal shadowing. But the opposite is possible. We can shadow let using let.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var x = 4;
{
  let x = 7;
};
--------------------------------------
let x = 4;
{
  let x = 7;
};
--------------------------------------
const x = 4;
{
  const x = 7; // This is also possible
};

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Credits to Akshay Saini.&lt;/em&gt;&lt;/strong&gt; [(&lt;a href="https://youtu.be/lW_erSjyMeM?si=2sy5sBnA8mgfLVRn)" rel="noopener noreferrer"&gt;https://youtu.be/lW_erSjyMeM?si=2sy5sBnA8mgfLVRn)&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>What are Scope, Scope Chain, and Lexical Environment?🔥</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Sat, 23 Nov 2024 18:29:50 +0000</pubDate>
      <link>https://dev.to/ramya_srim/what-are-scope-scope-chain-and-lexical-environment-3cob</link>
      <guid>https://dev.to/ramya_srim/what-are-scope-scope-chain-and-lexical-environment-3cob</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Scope&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scope refers to the areas in our code where a specific variable or function can be accessed.&lt;/li&gt;
&lt;li&gt;Scope in JavaScript is directly related to the Lexical Environment.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function x(){
  console.log(y); //It can access y, which is defined outside the function.
}
var y = 10;
x();    // 10
-------------------------------------------------------------------------
function x(){
  z();
  function z(){
    console.log(y); 
  };
};
var y = 10;
x();    // 10

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Lexical Environment&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whenever an Execution Context is created, a Lexical Environment is also created. The Lexical Environment consists of the local memory along with a reference to the lexical environment of its parent. 'Lexical' refers to hierarchy, sequence, or order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Local Memory + Reference to the Lexical Environment of its parent.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Scope Chain&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The chain of all lexical environment references to parent contexts is known as the Scope Chain. The process of finding y through this chain is referred to as Scope Chain resolution.&lt;/p&gt;

&lt;p&gt;Whenever code is executed, a Global Execution Context is created. When the Global Execution Context is created, it is pushed onto the call stack.&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%2Fihzbzqh3tiwldnob864v.jpeg" 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%2Fihzbzqh3tiwldnob864v.jpeg" alt="lexical and scope chain" width="800" height="858"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GEC =&amp;gt; Global Execution Context&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;M =&amp;gt; Memory Component&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;C =&amp;gt; Code Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"y" is lexically inside the "x" function, and "x" is lexically inside the Global Execution Context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Refer to the above diagram.&lt;/strong&gt; Assume the red box represents a reference to the lexical environment of its parent. &lt;/p&gt;

&lt;p&gt;The lexical parent of z is x() because z is lexically inside x(). The z function has a red box, which refers to the lexical environment of x() (i.e., z's memory space + the lexical environment of its parent). Similarly, x has a red box that references its own memory space and the lexical environment of its parent (GEC). The lexical environment of the global parent is null because there is no further lexical environment to search. At this point, the program stops, and the JavaScript engine throws 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;//Case 1

function x(){
  var y = 10;
  z();
  function z(){
    console.log(y); 
  };
};
x();    // 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;In Case 1&lt;/strong&gt; The JavaScript engine will first try to find the value of y inside the local memory of z(). If it is not found there, it will check the lexical environment of its parent, x(). In the local memory of x(), the engine finds the value of y.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Case 2

function x(){
  z();
  function z(){
    console.log(y);   // ReferenceError: y is not defined.
  };
};
x();  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;In Case 2&lt;/strong&gt; The JavaScript engine will first try to find the value of y inside the local memory of z(). If it is not found there, it will look in the lexical environment of its parent, x(). The engine will then check the local memory of x(). If the value is still not found, it will proceed to the lexical environment of the global execution context (GEC). The GEC will search for the value in its local memory. If the value is not found there either, and the lexical environment of the global context points to null, the program stops. At this point, the JavaScript engine throws an error stating that &lt;strong&gt;y is not defined&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Credits to Akshay Saini.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Var Vs Let Vs Const</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Fri, 22 Nov 2024 17:26:24 +0000</pubDate>
      <link>https://dev.to/ramya_srim/var-vs-let-vs-const-25aj</link>
      <guid>https://dev.to/ramya_srim/var-vs-let-vs-const-25aj</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Var&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = 11;
{
var a = 8;
};
console.log(a);// 8
-------------------------------------------------------------------------
var a = 11;
{
a = 28;
};
console.log(a);// 28
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Variables declared with var are in the global scope. We can access a var variable even outside a block because it is not block-scoped. Additionally, we can redeclare and reassign a var variable both inside and outside a block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Let&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    let a = 24;
}
console.log(a);// ReferenceError: a is not defined
-------------------------------------------------------------------------
{
    let a = 24;
    console.log(a);// 24
}
-------------------------------------------------------------------------
{
    let a = 24;
    a = 20;
    console.log(a);// 20
}// 
-------------------------------------------------------------------------
{
    let a = 24;
    let a = 20;
    console.log(a);//SyntaxError: Identifier 'a' has already been declared
}
-------------------------------------------------------------------------
let a = 20;
{
let a = 24;
console.log(a);// 24
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let has a separate memory space and block scope. Variables declared with let cannot be accessed outside the block because they are not in the global scope. We can reassign a let variable. However, we cannot redeclare the same variable within the same block, but we can redeclare it in a different block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Const&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  const x = 4;  
}
console.log(x);//ReferenceError: x is not defined
-------------------------------------------------------------------------
{
  const x = 4;  
  console.log(x) ;// 4
}
-------------------------------------------------------------------------
{
  const x = 4;  
  const x = 2;  
}
console.log(x);//SyntaxError: Identifier 'x' has already been declared
-------------------------------------------------------------------------
{
  const x = 4;   
}
const x = 2;
console.log(x);// 2
-------------------------------------------------------------------------
const x = 2;// we can access the global(x)
{
  const x = 4;   // we cannot access the outside block
}
console.log(x);// 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;const has a separate memory space and is block-scoped. Once a value is declared and initialized with const, it cannot be redeclared or reassigned. We cannot access a const variable outside its block because it is not in the global scope. We cannot redeclare the variable within the same block, but we can redeclare it outside the block.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Are let and const hoisted?🤔 What is the Temporal Dead Zone?</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Thu, 21 Nov 2024 18:28:29 +0000</pubDate>
      <link>https://dev.to/ramya_srim/are-let-and-const-hoisted-what-is-the-temporal-dead-zone-56jo</link>
      <guid>https://dev.to/ramya_srim/are-let-and-const-hoisted-what-is-the-temporal-dead-zone-56jo</guid>
      <description>&lt;p&gt;Yes, &lt;strong&gt;let&lt;/strong&gt; and &lt;strong&gt;const&lt;/strong&gt; declarations are hoisted, but they are hoisted differently from var declarations.&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(b); // undefined
let a = 12;
var b = 28;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We know that we can access "b" even before it is initialized. It does not give an error but instead returns a special value: undefined.&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); // Uncaught ReferenceError: Cannot access 'a' before initialization
let a = 12;
var b = 28;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code gives an error, indicating that the variable can only be accessed after it is initialized.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = 12;
console.log(a); // 12
var b = 28;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript allocates memory for "a" and "b" even before a single line of code is executed. In the case of var(b), it is in the global space, while for let(a), it is in the script scope. The memory assigned to "b" is attached to the global object. Although let and const also have allocated memory, they exist in a separate memory space. This memory space for let and const declarations cannot be accessed before they are initialized.&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);

let a = 12; //TDZ Ends

var b = 28;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The period from when the let variable is hoisted until it is initialized with a value is called the Temporal Dead Zone. If we try to access a variable inside the Temporal Dead Zone, it results in a ReferenceError. In this code, JavaScript allocates memory for "a" in the script (as undefined) even before execution begins. The variable "a" remains in the Temporal Dead Zone until a value is assigned. Anything before the line (let a = 12) represents the Temporal Dead Zone for "a".&lt;/p&gt;

&lt;p&gt;let is stricter than var, and const is even stricter than let.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
let a;
a = 11;
console.log(a); // 11 --&amp;gt; We can declare and assign a on different lines.
-------------------------------------------------------------------------
const b;
b = 28;
console.log(b);//Uncaught SyntaxError: Missing initializer in const declaration.(We have to initialize it on the same line.(Like this--&amp;gt;const b = 28))
-------------------------------------------------------------------------
const b = 30;
b = 28;
console.log(b);//script.js:37 Uncaught TypeError: Assignment to constant variable.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Credits to Akshay Saini.&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>learning</category>
    </item>
    <item>
      <title>Undefined Vs Not defined</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Wed, 20 Nov 2024 17:51:13 +0000</pubDate>
      <link>https://dev.to/ramya_srim/undefined-vs-not-defined-2he1</link>
      <guid>https://dev.to/ramya_srim/undefined-vs-not-defined-2he1</guid>
      <description>&lt;p&gt;First, we need to understand the JavaScript Code Execution process, which consists of two phases: the Memory Creation Phase and the Code Execution Phase. Both 'undefined' and 'not defined' are related to memory space.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;undefined&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;In the Memory Creation Phase, variables and functions are stored as key-value pairs. JavaScript assigns undefined to each variable as a placeholder. This temporary value stays until JavaScript finds the real value, then it replaces undefined with the real one. Don't assign undefined to any variables; it's not a good practice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var x ;
console.log(x);// undefined
x = 2;
console.log(x); //2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;&lt;strong&gt;not defined&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript, if a variable is not declared at all and we try to access it, it will throw a ReferenceError.&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(x);//ReferenceError: x is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;credits to Akshay Saini&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://dev.tourl"&gt; https://youtu.be/B7iF6G3EyIk?si=0WQLx-yjVOgdkkIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>learning</category>
    </item>
    <item>
      <title>Hoisting in JS</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Tue, 19 Nov 2024 18:17:20 +0000</pubDate>
      <link>https://dev.to/ramya_srim/hoisting-in-js-5ghc</link>
      <guid>https://dev.to/ramya_srim/hoisting-in-js-5ghc</guid>
      <description>&lt;p&gt;In JavaScript, we can access the variables and functions even before they are initialized or assigned a value.&lt;/p&gt;

&lt;p&gt;Look at the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;greet(); //JavaScript
console.log(x);//Undefined
function greet(){
   console.log("JavaScript")
};
var x = 28;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In many other programming languages, this would result in an error. However, in JavaScript, this code runs without any error. JavaScript executes code line by line, but before execution, memory is allocated for all variables and functions. During the two phases—Memory Creation and Code Execution—the Memory Creation Phase assigns undefined to variables(x) and stores the entire function code(greet()) in memory. Here, we are trying to access greet even before it is initialized (We can access the function anywhere before it is initialized). If we remove (x = 28), it will result in an Uncaught ReferenceError: x is not defined.&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(greet); //ƒ greet(){console.log("JavaScript");}
console.log(x);//Uncaught ReferenceError: x is not defined
function greet(){
   console.log("JavaScript");
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hoisting is the concept of moving declarations to the top of their scope during the compile phase, before the code is executed. Declaring a variable or function means creating or defining its name so that the JavaScript engine recognizes its existence. Initialization refers to assigning a value to a declared variable or defining the code inside a function. In JavaScript, var is hoisted. However, only the declaration is hoisted, not the initialization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;greet(); //Declaring a function
var x; // Declaring a variable
console.log(x);//Undefined
function greet(){
   console.log("JavaScript")
};
x = 28;// Initializing a variable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;greet()
var greet = () =&amp;gt; {
   console.log("JavaScript");
 }; //Uncaught TypeError: greet is not a function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we run this code, we will get an error. This will happen because, during the memory creation phase, greet will be assigned undefined, as it will be treated as a variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Credits to Akshay Saini.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>learning</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Scope in JavaScript</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Fri, 04 Oct 2024 16:03:37 +0000</pubDate>
      <link>https://dev.to/ramya_srim/scope-in-javascript-2n5d</link>
      <guid>https://dev.to/ramya_srim/scope-in-javascript-2n5d</guid>
      <description>&lt;p&gt;In JavaScript, Scope defines how variables are accessed and managed throughout the program. There are four types of scope: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Global Scope&lt;/li&gt;
&lt;li&gt;Local Scope&lt;/li&gt;
&lt;li&gt;Block Scope&lt;/li&gt;
&lt;li&gt;Module Scope&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Global Scope&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Global scope is defined by variables that are declared outside of any function and can be accessed anywhere in the program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var gVar = "Global Scope";
function globalScope(){
   console.log(gVar)
}
globalScope()
console.log(gVar)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/strong&gt;&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%2Fe8uxn4tt21x6185dx1nv.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%2Fe8uxn4tt21x6185dx1nv.png" alt="Global Scope" width="800" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Local Scope&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Local scope is defined by variables that are declared inside a function and can be accessed only within that function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function localScope(){
   var lVar = "Local Scope";
   console.log(lVar)
}

localScope()
console.log(lVar)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/strong&gt;&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%2F1k5f03pp99xg7b4zy0j6.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%2F1k5f03pp99xg7b4zy0j6.png" alt="Local Scope" width="800" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Block Scope&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before ES6, JavaScript had only two types of scope: global scope and local scope. After ES6, two new keywords, let and const, were introduced. These keywords provide block scope in JavaScript. A block is defined by { } and variables declared inside a block can only be accessed within that block.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function blockScope(){
   let blockVar = "Block Scope";
   console.log(blockVar);
}
blockScope()
console.log(blockVar);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/strong&gt;&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%2F04rcjah4i4h9oadk23pp.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%2F04rcjah4i4h9oadk23pp.png" alt="Block Scope" width="800" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Module Scope&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Module scope was officially introduced in JavaScript with ES6. In ES6, each module has its own scope, meaning variables and functions inside a module are private unless explicitly exported. This version introduced the import and export keywords, allowing modules to communicate with each other.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Export: Allows you to share variables, functions, or classes from a module.&lt;/li&gt;
&lt;li&gt;Import: Allows you to bring in variables, functions, or classes from another module.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this explanation clarifies the concept. If you have any questions or corrections, feel free to ask in the comments.&lt;/p&gt;

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