<?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.us-east-2.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>Blink Board: Asking for water with one long blink and a laptop webcam</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Mon, 23 Nov 2026 06:09:28 +0000</pubDate>
      <link>https://dev.to/ramya_srim/blink-board-asking-for-water-with-one-long-blink-and-a-laptop-webcam-1bgo</link>
      <guid>https://dev.to/ramya_srim/blink-board-asking-for-water-with-one-long-blink-and-a-laptop-webcam-1bgo</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/presage-2026-11-04"&gt;Presage SmartSpectra SDK Challenge&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Blink Board&lt;/strong&gt; is a desktop communication aid for people who can't speak or use their hands. Six large tiles (&lt;em&gt;Water, Washroom, Pain, Too hot/cold, Call someone, Yes / No&lt;/em&gt;) light up one at a time. To choose one, do a &lt;strong&gt;long blink&lt;/strong&gt; while it's highlighted: close your eyes, wait for a soft beep, then open them, and the word is spoken aloud.&lt;/p&gt;

&lt;p&gt;That's the whole interaction: no hands, no voice, no special hardware—just a laptop webcam.&lt;/p&gt;

&lt;p&gt;When someone can't speak, their family often has to guess what they need. I wanted to see if an ordinary laptop webcam could give that person back a few of the most important words, like &lt;em&gt;water&lt;/em&gt;, &lt;em&gt;pain&lt;/em&gt; and &lt;em&gt;call someone&lt;/em&gt;, with something a family could set up on a normal laptop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The flow:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Consent screen.&lt;/strong&gt; The camera stays off until you press Start.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blink calibration&lt;/strong&gt; (~10 s, with spoken prompts). "Keep your eyes open…", then "Now close your eyes until you hear a beep." The app learns what &lt;em&gt;your&lt;/em&gt; open and closed eyes look like.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The board.&lt;/strong&gt; Tiles are highlighted every 1.5 s. A long blink chooses; normal blinks do nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy view.&lt;/strong&gt; Instead of the camera picture, the screen shows only face dots on a dark background, and the eye dots turn green when your eyes count as closed.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Blink Board is &lt;strong&gt;not a medical device&lt;/strong&gt;, makes no health claims, and shouldn't be anyone's only way to communicate.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;▶️ &lt;strong&gt;Watch the demo video:&lt;/strong&gt; &lt;a href="https://www.loom.com/share/f197e24798a1486e9d79f4aebd200473" rel="noopener noreferrer"&gt;https://www.loom.com/share/f197e24798a1486e9d79f4aebd200473&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/RamyaSriMohanrao" rel="noopener noreferrer"&gt;
        RamyaSriMohanrao
      &lt;/a&gt; / &lt;a href="https://github.com/RamyaSriMohanrao/blink-board" rel="noopener noreferrer"&gt;
        blink-board
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Blink Board&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;A prototype communication aid for people who can't speak or use their hands
Large tiles light up one by one. The user picks the lit tile with a long
deliberate blink, and the app speaks the word aloud.&lt;/p&gt;
&lt;p&gt;It uses the &lt;a href="https://smartspectra.presagetech.com/docs/nodejs" rel="nofollow noopener noreferrer"&gt;Presage SmartSpectra SDK&lt;/a&gt;
to read the face from a webcam, and runs as a desktop app (Electron).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Not a medical device.&lt;/strong&gt; Blink Board is a prototype. It makes no health claims,
doesn't diagnose or monitor anything, and &lt;strong&gt;should not be anyone's only way to
communicate&lt;/strong&gt;. Lighting, glasses, camera angle, tiredness and involuntary blinks can
all cause missed or wrong choices.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;How it works&lt;/h2&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Consent screen.&lt;/strong&gt; The camera stays off until you press &lt;strong&gt;Start&lt;/strong&gt; (or &lt;strong&gt;Camera check&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blink calibration&lt;/strong&gt; (about 10 seconds, with spoken prompts): keep your eyes open
then close them until you hear a beep. The app learns what &lt;em&gt;your&lt;/em&gt; open and closed
eyes…&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/RamyaSriMohanrao/blink-board" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;The README covers setup (&lt;code&gt;npm ci&lt;/code&gt;, an API key in &lt;code&gt;.env&lt;/code&gt;, &lt;code&gt;npm start&lt;/code&gt;), troubleshooting, and a full "Camera consent &amp;amp; data handling" section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stack:&lt;/strong&gt; Electron 45 + &lt;code&gt;@smartspectra/node-sdk&lt;/code&gt; 3.5.0, using Presage's recommended three-process setup (&lt;code&gt;bindSmartSpectraIpc&lt;/code&gt; in main, the SDK preload with &lt;code&gt;contextIsolation&lt;/code&gt; and &lt;code&gt;sandbox&lt;/code&gt;, the SDK in the renderer). Plain JavaScript, bundled with esbuild. No server, no database, no AI service. &lt;/p&gt;

&lt;p&gt;I built Blink Board with &lt;strong&gt;Claude Code&lt;/strong&gt; as my coding assistant, working in phases: consent and an SDK debug panel, then calibration and the board, the privacy view, and the README.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Responds to Human Signals
&lt;/h2&gt;

&lt;p&gt;Blink Board doesn't use pulse or breathing. Its live signal is &lt;strong&gt;the eyes&lt;/strong&gt;, from SmartSpectra's face metrics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sdk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SmartSpectraSDK&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;requestedMetrics&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;MetricType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;FACE_LANDMARKS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;MetricType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;BLINKING&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;enableTelemetry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;sdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'metrics'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;decodeMetrics&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;processLandmarks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;face&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;landmarks&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 478 points, ~30 sets/s&lt;/span&gt;
  &lt;span class="nf"&gt;processBlinking&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;face&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blinking&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Simplified; the full code is in &lt;code&gt;src/renderer/app.js&lt;/code&gt;.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I learned about &lt;code&gt;BLINKING&lt;/code&gt;:&lt;/strong&gt; my first plan was to time a "long blink" with the SDK's &lt;code&gt;BLINKING&lt;/code&gt; metric. Phase 1 of the project was a debug panel to measure it, and it showed that &lt;code&gt;detected&lt;/code&gt; is a short &lt;em&gt;event&lt;/em&gt;: normal blinks read about 30–210 ms, and even with my eyes closed for 2–3 seconds it never went above 208 ms. Great for counting blinks, but it can't tell a deliberate hold from a normal blink.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So the long blink comes from Presage's landmarks.&lt;/strong&gt; From the fixed eye points in the 478-point layout, I compute eye openness (eye height ÷ eye width):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;openness&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;dist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;upper1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lower1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;dist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;upper2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lower2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;dist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outerCorner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;innerCorner&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In testing it read about &lt;strong&gt;0.28 with eyes open and as low as 0.08 closed&lt;/strong&gt;, and it timed real closures accurately: two normal blinks logged as 96 and 144 ms, two deliberate closures as 1393 and 2928 ms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the experience responds in real time:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Eyes close → scanning freezes&lt;/strong&gt; on the tile that was highlighted &lt;em&gt;at the moment they closed&lt;/em&gt;. I use the SDK timestamp of the closure, so processing lag can't shift the choice to the next tile.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;0.5 s → a beep&lt;/strong&gt;, because the person can't see the screen with their eyes shut.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eyes open between 0.5 and 3 s → selected&lt;/strong&gt;, and the word is spoken with a local Windows voice. Closures longer than 3 s (resting, dozing) are ignored, so nothing is chosen by accident.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Face lost → scanning pauses by itself.&lt;/strong&gt; The app uses SmartSpectra's validation status (&lt;code&gt;kNoFaceFound&lt;/code&gt;, &lt;code&gt;kMultipleFacesFound&lt;/code&gt;) and the flow of landmarks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Calibration&lt;/strong&gt; sets each person's closed line between &lt;em&gt;their&lt;/em&gt; measured open and closed values, with hysteresis so the state doesn't flicker.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The privacy view&lt;/strong&gt; is drawn live from the same landmarks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Best Thoughtful Real-World Use.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The need:&lt;/strong&gt; some people, for a while or for good, can't speak or use their hands, but can still control their eyes. Eye-controlled communication aids exist, but often need special hardware. Blink Board explores what's possible with only a normal laptop webcam.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Designed for the person using it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Huge tiles and one action.&lt;/strong&gt; A long blink is the only input. No gaze accuracy needed, just one deliberate gesture.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audio cues for closed eyes.&lt;/strong&gt; The beep tells you when you can let go; you can't see the screen with your eyes shut.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hard to trigger by accident.&lt;/strong&gt; Normal blinks, closures over 3 s, and moments when the face isn't visible never choose anything. After a choice there's a 1 s pause, and the eyes must open before the next one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Personal calibration&lt;/strong&gt;, because everyone's eyes are different.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caregiver controls:&lt;/strong&gt; Pause, Resume and Recalibrate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy view on by default&lt;/strong&gt;, so a face isn't on show to everyone in the room.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What's next:&lt;/strong&gt; an editable board, a spelling mode, and testing with real users and caregivers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Consent and Data Handling
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consent before the camera.&lt;/strong&gt; The first screen explains, in plain words, how the camera and data are used, that SDK telemetry is off, and that this is not a medical device. The camera starts only when the user presses &lt;strong&gt;Start&lt;/strong&gt;, and &lt;strong&gt;Stop&lt;/strong&gt; fully releases it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Video is processed on this computer.&lt;/strong&gt; Frames are processed in memory by the SmartSpectra SDK. Blink Board itself &lt;strong&gt;never records, saves or uploads video, images or readings&lt;/strong&gt;, and has no server or database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SDK telemetry is off.&lt;/strong&gt; The app requests it off, and the main process forces &lt;code&gt;enableTelemetry: false&lt;/code&gt; whatever the page sends.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network:&lt;/strong&gt; the SDK still contacts Presage's servers to verify the API key and device. Blink Board itself sends nothing anywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage and deletion:&lt;/strong&gt; Blink Board saves no video, images or readings. Calibration lives in memory and is forgotten when the app closes. The SDK keeps a small local cache (including a device key), and Electron keeps housekeeping files, both under &lt;code&gt;%APPDATA%\blink-board&lt;/code&gt;. Blink Board writes no video or readings there. The README explains how to delete them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The API key&lt;/strong&gt; is read only in Electron's main process and never reaches the app window. It's redacted from error text and logs, and excluded from git.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speech&lt;/strong&gt; uses only voices installed on the computer, so spoken words never go to an online service. &lt;strong&gt;No AI service&lt;/strong&gt; is used in the app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No covert monitoring.&lt;/strong&gt; The camera works only after consent, and only during a session the user starts and can stop at any time.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>presagechallenge</category>
      <category>electron</category>
      <category>showdev</category>
    </item>
    <item>
      <title>From Understanding Gemma 4 🧠 to Building SpeakUp 🎙️ — An AI English Coach 🤖</title>
      <dc:creator>Ramya Sri M</dc:creator>
      <pubDate>Mon, 25 May 2026 00:44:03 +0000</pubDate>
      <link>https://dev.to/ramya_srim/from-understanding-gemma-4-to-building-speakup-an-ai-english-coach-3flh</link>
      <guid>https://dev.to/ramya_srim/from-understanding-gemma-4-to-building-speakup-an-ai-english-coach-3flh</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/google-gemma-2026-05-06"&gt;Gemma 4 Challenge: Write About Gemma 4&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why I Started This&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Millions of people want to learn English but cannot afford a private tutor. For many families, this is too expensive. So I decided to build one using AI. Not just a simple chatbot but a real English coach for everyone, from a 7-year-old child 👧 to a 60-year-old adult👴. I called it SpeakUp and it is powered by Gemma 4. I am still actively building it. But before I show you SpeakUp, I want to explain Gemma 4 in a simple way. By the end of this article, it will be clear what Gemma 4 is, how it works, and how I am using it to build SpeakUp.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Gemma 4?🤖&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gemma 4 is an open-source AI model built by Google DeepMind, released under the Apache 2.0 license — free to use, modify, and build with.&lt;/p&gt;

&lt;p&gt;There are two ways to use it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;💻Run locally via Ollama&lt;br&gt;
=&amp;gt; No internet or API key needed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;☁️ Access via Google AI Studio API&lt;br&gt;
=&amp;gt; Internet and API key needed&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Running it locally means Gemma 4 runs entirely on your own device — no data leaves your machine, no subscription needed. Accessing it via Google AI Studio API means Gemma 4 runs on Google's servers and your app communicates with it over the internet.&lt;/p&gt;

&lt;p&gt;Gemma 4 is well-suited for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📝Text generation&lt;/li&gt;
&lt;li&gt;💻Coding assistance&lt;/li&gt;
&lt;li&gt;🧠Reasoning &lt;/li&gt;
&lt;li&gt;🖼️Image understanding&lt;/li&gt;
&lt;li&gt;🔧Function calling and building agentic applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Four Gemma 4 Models📦&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gemma 4 has four models — E2B, E4B, 26B A4B, and 31B.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;E2B — 📱Effective 2 Billion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The "E" stands for Effective. E2B is the smallest model in the Gemma 4 family. It has 5.1B total parameters but runs with the speed and memory of a much smaller 2.3B model. This is possible because of a technique called Per-Layer Embeddings (PLE) — instead of loading everything at once, each layer of the model gets only the small piece of information it needs. This makes it light, fast, and perfect for phones and low-memory devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;E4B — 💻Effective 4 Billion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;E4B works the same way as E2B using PLE. It has 8B total parameters but runs with the speed and memory of a 4.5B model. It is smarter than E2B and better suited for complex reasoning, while still running on everyday laptops.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;26B A4B — Mixture of Experts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The "A" stands for Active. This model has 26B total parameters, but only activates around 4B of them per request. This makes it faster, cheaper, and more efficient while still having access to the full 26B knowledge base.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;31B Dense&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The 31B Dense model uses all 30.7 billion parameters for every single request — the most thorough and accurate reasoning in the family.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multimodal Capabilities&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All four models handle text and image inputs. E2B and E4B also support audio up to 30 seconds🎵. All generate text output only. And maintains multilingual support in over 140 languages🌍.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding the Building Blocks🔬&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameters — 🧠Intelligence Capacity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Parameters are the learned knowledge connections inside an AI. More parameters usually means more intelligence, better reasoning, and better understanding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layers — 🏢Depth of Reasoning&lt;/strong&gt;&lt;br&gt;
Layers are the stages of thinking inside an AI. Each layer processes the input and passes a richer understanding to the next layer. &lt;br&gt;
More layers = deeper thinking = better understanding of complex meaning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Embeddings — The Language Translation Layer🔤&lt;/strong&gt;&lt;br&gt;
For E2B, total parameters = 2.3B effective + embedding parameters = 5.1B total.&lt;/p&gt;

&lt;p&gt;Reasoning parameters (2.3B) — the actual thinking 🧠&lt;br&gt;
Embedding parameters (remaining) — the translation layer&lt;/p&gt;

&lt;p&gt;The 2.3B reasoning parameters are the actual “thinking” part of the AI. These parameters help the model understand questions, reason, and generate answers.&lt;br&gt;
The remaining parameters are embedding parameters. Their job is to convert words and tokens into a mathematical form that the AI can understand internally.&lt;/p&gt;

&lt;p&gt;So even though E2B has 5.1B total parameters, only 2.3B are mainly used for reasoning, which is why it behaves like a smaller and more efficient model.&lt;/p&gt;

&lt;p&gt;Embeddings convert words, sentences, and meaning into numbers that the AI understands internally. For example, the word "cat" becomes a series of numbers inside the model. Embeddings are the language translation layer for the AI brain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tokens and Vocabulary — How AI Reads Text 📖&lt;/strong&gt;&lt;br&gt;
Vocabulary means how many tokens the AI understands. But tokens are not the same as words.&lt;br&gt;
Tokens can be:&lt;/p&gt;

&lt;p&gt;Full words — "cat" = 1 token&lt;br&gt;
Parts of words — "unbelievable" = 3 tokens (un / believe / able)&lt;br&gt;
Symbols and punctuation — "!" = 1 token&lt;br&gt;
Code snippets and special characters&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Context Length —  💾Total Memory Size&lt;/strong&gt;&lt;br&gt;
Context length means how much information the AI can remember at once during a conversation. It is measured in tokens.&lt;/p&gt;

&lt;p&gt;128K tokens = approximately 90,000 words = a full novel 📗&lt;br&gt;
256K tokens = approximately 180,000 words = two full novels 📗📗&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sliding Window — Local Attention Memory 🪟&lt;/strong&gt;&lt;br&gt;
Instead of looking at all tokens at once (which would be very slow), the AI focuses on nearby chunks or windows at a time. This is called sliding window attention.&lt;br&gt;
Gemma 4 uses a hybrid approach — local sliding window attention for speed⚡, and global attention every few layers to capture the big picture. The final layer is always global — so Gemma 4 always ends with a complete view before generating its reply.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is SpeakUp?🎙️&lt;/strong&gt;&lt;br&gt;
SpeakUp is an AI-powered English learning web app. It runs in Chrome, built with Python (FastAPI) on the backend and plain HTML, CSS and JavaScript on the frontend. Gemma 4 powers every feature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two modes:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👤Adult mode — precise grammar rules, professional tone, detailed explanations&lt;br&gt;
👶Kids mode — one toggle transforms the entire app — larger text, simpler words, encouraging tone, slower voice&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;📚 Grammar Lessons A to Z&lt;/li&gt;
&lt;li&gt;✅ Grammar Correction&lt;/li&gt;
&lt;li&gt;🎧 Listening Practice&lt;/li&gt;
&lt;li&gt;📖 Reading Practice&lt;/li&gt;
&lt;li&gt;✍️ Writing Practice&lt;/li&gt;
&lt;li&gt;🤝 Speaking Partner&lt;/li&gt;
&lt;li&gt;🔁 Shadowing&lt;/li&gt;
&lt;li&gt;🗣️ Pronunciation Check&lt;/li&gt;
&lt;li&gt;🎯 Quiz with Celebrations&lt;/li&gt;
&lt;li&gt;🧩 Word Scramble&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Challenge — The RAM Problem⚠️&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I downloaded the E4B model successfully. Everything looked fine. But the moment I tried to run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;model requires more system memory (9.8 GiB) than is available (4.9 GiB)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My laptop has 8GB total RAM. After Windows took its share, only 4.9 GB was free. E4B needs 9.8 GB. It would not load.&lt;br&gt;
The solution was Google AI Studio. I switched to the 26B A4B model running on Google's servers via the free API. &lt;br&gt;
The offline option is still there. Any user with 10+ GB free RAM can switch to local Ollama by changing one line in main.py.&lt;/p&gt;

&lt;p&gt;SpeakUp is still in progress, but it already shows how AI can make English learning more accessible and practical for everyone🌍.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>gemma</category>
      <category>ai</category>
      <category>gemmachallenge</category>
    </item>
    <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="788"&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>
  </channel>
</rss>
