<?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: ronak wanjari</title>
    <description>The latest articles on DEV Community by ronak wanjari (@ronak_wanjari_).</description>
    <link>https://dev.to/ronak_wanjari_</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%2F3246943%2F14bc08b3-a9d8-4503-9d17-446c35eb0e62.png</url>
      <title>DEV Community: ronak wanjari</title>
      <link>https://dev.to/ronak_wanjari_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ronak_wanjari_"/>
    <language>en</language>
    <item>
      <title>🔍 Understanding Scope, Scope Chain &amp; Lexical Environment in JavaScript</title>
      <dc:creator>ronak wanjari</dc:creator>
      <pubDate>Sat, 14 Jun 2025 12:28:44 +0000</pubDate>
      <link>https://dev.to/ronak_wanjari_/understanding-scope-scope-chain-lexical-environment-in-javascript-39en</link>
      <guid>https://dev.to/ronak_wanjari_/understanding-scope-scope-chain-lexical-environment-in-javascript-39en</guid>
      <description>&lt;p&gt;By Ronak Wanjari | Intern at Devsync.in &lt;a class="mentioned-user" href="https://dev.to/devsyncin"&gt;@devsyncin&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you’re learning JavaScript (like me, at Devsync.in 🚀), you've probably heard terms like scope, scope chain, and lexical environment. These are core concepts that govern how variables are accessed in JS. Let’s break them down simply.&lt;/p&gt;

&lt;p&gt;🌐 What is Scope in JavaScript?&lt;br&gt;
Scope is the context in which variables are declared and accessed. JavaScript has:&lt;/p&gt;

&lt;p&gt;Global Scope: Accessible everywhere.&lt;/p&gt;

&lt;p&gt;Function/Local Scope: Variables declared inside a function can't be accessed outside.&lt;/p&gt;

&lt;p&gt;Block Scope (ES6): Variables declared using let and const are limited to {} block.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let globalVar = '🌍';

function show() {
  let localVar = '🔒';
  console.log(globalVar); // ✅ Accessible
  console.log(localVar);  // ✅ Accessible
}
console.log(localVar); // ❌ Error

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

&lt;/div&gt;



&lt;p&gt;🔗 What is Scope Chain?&lt;/p&gt;

&lt;p&gt;When you try to access a variable, JavaScript looks in the current scope, and if it doesn't find it, it travels up the chain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = 'Ronak';

function greet() {
  const greeting = 'Hello';

  function sayHi() {
    console.log(greeting + ' ' + name); 
    // JS first checks sayHi -&amp;gt; greet -&amp;gt; global
  }

  sayHi();
}
Scope chain = sayHi → greet → global
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧠 What is Lexical Environment?&lt;/p&gt;

&lt;p&gt;Every time a function is created, it gets a Lexical Environment, which is a structure that holds the variable references. It has two parts:&lt;/p&gt;

&lt;p&gt;Environment Record → Stores variables/functions.&lt;/p&gt;

&lt;p&gt;Outer Lexical Environment Reference → Points to parent scope.&lt;/p&gt;

&lt;p&gt;This is why inner functions can access outer variables — it's defined lexically (by location in code).&lt;/p&gt;

&lt;p&gt;🔥 Final Thoughts&lt;/p&gt;

&lt;p&gt;Scope controls where your variables live.&lt;/p&gt;

&lt;p&gt;Scope chain helps JavaScript find them.&lt;/p&gt;

&lt;p&gt;Lexical Environment is how they are stored and linked.&lt;/p&gt;

&lt;p&gt;Understanding this trio is key to writing bug-free, clean JavaScript code.&lt;br&gt;
I’m learning these during my internship at devsync.in — and it's helping me a lot! 💻✨&lt;/p&gt;

&lt;p&gt;Mentored and guided by &lt;a class="mentioned-user" href="https://dev.to/devsyncin"&gt;@devsyncin&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  JavaScript #Scope #Devsync #LexicalEnvironment #WebDev #JSIntern
&lt;/h1&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🔍 How Functions Work in JavaScript ❤️ &amp; Variable Environment</title>
      <dc:creator>ronak wanjari</dc:creator>
      <pubDate>Fri, 13 Jun 2025 15:20:22 +0000</pubDate>
      <link>https://dev.to/ronak_wanjari_/how-functions-work-in-javascript-variable-environment-h6l</link>
      <guid>https://dev.to/ronak_wanjari_/how-functions-work-in-javascript-variable-environment-h6l</guid>
      <description>&lt;p&gt;By Ronak Wanjari | Intern at &lt;a class="mentioned-user" href="https://dev.to/devsyncin"&gt;@devsyncin&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Functions are the heart of JavaScript, and understanding how they work internally helps write better and cleaner code. As I learned during my internship at &lt;a class="mentioned-user" href="https://dev.to/devsyncin"&gt;@devsyncin&lt;/a&gt; , every function in JavaScript creates its own world called the Execution Context when it runs.&lt;/p&gt;

&lt;p&gt;🧠 &lt;strong&gt;What's Inside a Function Execution?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a function is invoked, JavaScript creates:&lt;/p&gt;

&lt;p&gt;📦 A Variable Environment – stores variables and parameters.&lt;/p&gt;

&lt;p&gt;🔗 A Scope Chain – connects it to outer environments.&lt;/p&gt;

&lt;p&gt;🧍‍♂️ A this keyword – depends on how the function is called.&lt;/p&gt;

&lt;p&gt;📌** Understanding Variable Environment**&lt;/p&gt;

&lt;p&gt;The Variable Environment includes:&lt;/p&gt;

&lt;p&gt;Function parameters&lt;/p&gt;

&lt;p&gt;Variables (var, let, const)&lt;/p&gt;

&lt;p&gt;Inner function declarations&lt;/p&gt;

&lt;p&gt;This environment is temporary and recreated every time the function is called.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greet(name) {
  let message = "Hello " + name;
  return message;
}
Each call to greet("Ronak") creates a fresh environment with name = "Ronak" and message = "Hello Ronak".
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧩 &lt;strong&gt;Hoisting &amp;amp; Variable Environment&lt;/strong&gt;&lt;br&gt;
Understanding variable environments makes hoisting easier to grasp. Variables declared with var are hoisted to the top of the environment, but only the declaration—not the value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function test() {
  console.log(x); // undefined
  var x = 5;
}
x exists in the environment but is undefined at first.

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

&lt;/div&gt;



&lt;p&gt;Mentored and guided by &lt;a class="mentioned-user" href="https://dev.to/devsyncin"&gt;@devsyncin&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  JavaScript #Functions #VariableEnvironment #Hoisting #WebDevelopment #Devsync
&lt;/h1&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🚫 Undefined vs Not Defined in JavaScript: What's the Difference?</title>
      <dc:creator>ronak wanjari</dc:creator>
      <pubDate>Fri, 13 Jun 2025 13:41:26 +0000</pubDate>
      <link>https://dev.to/ronak_wanjari_/undefined-vs-not-defined-in-javascript-whats-the-difference-48dg</link>
      <guid>https://dev.to/ronak_wanjari_/undefined-vs-not-defined-in-javascript-whats-the-difference-48dg</guid>
      <description>&lt;p&gt;By Ronak Wanjari | Intern at Devsync.in&lt;/p&gt;

&lt;p&gt;JavaScript is powerful — but sometimes, its behavior can feel a little confusing. One common pain point for developers, especially beginners, is understanding the difference between undefined and not defined. Although they might seem similar at first, they represent very different things under the hood.&lt;/p&gt;

&lt;p&gt;👨‍💻 I’m currently learning JavaScript as part of my internship at &lt;a class="mentioned-user" href="https://dev.to/devsyncin"&gt;@devsyncin&lt;/a&gt;, where we focus on building modern, scalable web applications. This blog reflects a hands-on concept I recently learned and found incredibly useful in avoiding bugs and writing clean code.&lt;/p&gt;

&lt;p&gt;🚦 &lt;strong&gt;Understanding undefined&lt;/strong&gt;&lt;br&gt;
When you declare a variable but don’t assign a value to it, JavaScript automatically gives it a value of undefined.&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;
console.log(a); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the variable a exists, but it hasn't been given any value yet — hence, it’s undefined. This isn't an error; it's JavaScript’s default behavior.&lt;/p&gt;

&lt;p&gt;❌ What Does "Not Defined" Mean?&lt;/p&gt;

&lt;p&gt;Now let’s look at a different scenario:&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); // ReferenceError: b is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, b was never declared — not with let, const, or var. So, when JavaScript encounters console.log(b), it throws a ReferenceError, saying that b is not defined.&lt;/p&gt;

&lt;p&gt;This error stops your program immediately. It usually means one of two things:&lt;br&gt;
*You forgot to declare the variable.&lt;br&gt;
*You made a typo in the variable name.&lt;/p&gt;

&lt;p&gt;🧩 &lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ undefined: The variable exists but has no value.&lt;/p&gt;

&lt;p&gt;❌ not defined: The variable doesn’t exist at all — and trying to use    it will crash your code.&lt;/p&gt;

&lt;p&gt;🔍 Use typeof to safely check for variable existence.&lt;/p&gt;

&lt;p&gt;Thanks to my ongoing internship at &lt;a class="mentioned-user" href="https://dev.to/devsyncin"&gt;@devsyncin&lt;/a&gt; , I’ve been able to learn these core JavaScript concepts through real-world tasks and challenges. Understanding the difference between undefined and not defined has not only helped me debug better but also write cleaner, more predictable code.&lt;/p&gt;

&lt;p&gt;#javascript #webdevelopment #programming #devsync #learnjavascript #beginners&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🚀 Understanding Hoisting in JavaScript: The Hidden Lift</title>
      <dc:creator>ronak wanjari</dc:creator>
      <pubDate>Thu, 05 Jun 2025 11:13:09 +0000</pubDate>
      <link>https://dev.to/ronak_wanjari_/understanding-hoisting-in-javascript-the-hidden-lift-48ce</link>
      <guid>https://dev.to/ronak_wanjari_/understanding-hoisting-in-javascript-the-hidden-lift-48ce</guid>
      <description>&lt;p&gt;By Ronak Wanjari | Intern at DevSync.in &lt;a class="mentioned-user" href="https://dev.to/devsyncin"&gt;@devsyncin&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;When working with JavaScript, developers often encounter a concept known as hoisting — a unique and sometimes confusing behavior for those new to the language. In this article, we break down what hoisting is, why it occurs, and how understanding it can improve the quality and predictability of your code.&lt;/p&gt;

&lt;p&gt;🔍 What Is Hoisting in JavaScript?&lt;br&gt;
Hoisting is a JavaScript mechanism where variable and function declarations are moved to the top of their scope (either global or functional) during the compilation phase — before the code is executed.&lt;/p&gt;

&lt;p&gt;It’s important to note that only declarations are hoisted, not initializations. This means a variable declared later in the code may be accessible earlier, but its value will be undefined until it's assigned.&lt;/p&gt;

&lt;p&gt;🧠 Why Does Hoisting Happen?&lt;br&gt;
JavaScript executes code in two phases: the compilation phase and the execution phase. During the compilation phase, the JavaScript engine scans for declarations and allocates memory for them. This behavior enables functions to be invoked before they appear in the code and prevents some reference errors — but it can also lead to unexpected results if not understood correctly.&lt;/p&gt;

&lt;p&gt;💡 Example: Variable Hoisting in Action&lt;br&gt;
Consider the following code:&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);
var a = 5;
Instead of throwing a ReferenceError, JavaScript returns undefined. Internally, the code is treated as:

&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;var a;
console.log(a); 
a = 5;
Only the declaration var a is hoisted, not the assignment a = 5.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔐 Key Takeaways&lt;br&gt;
var declarations are hoisted and initialized with undefined.&lt;/p&gt;

&lt;p&gt;let and const are also hoisted, but they remain uninitialized until the code reaches their definition. Accessing them before declaration results in a ReferenceError.&lt;/p&gt;

&lt;p&gt;Function declarations are fully hoisted, allowing them to be invoked before they appear in the code.&lt;/p&gt;

&lt;p&gt;Understanding hoisting is essential for writing predictable, maintainable, and bug-free JavaScript code.&lt;/p&gt;

&lt;p&gt;📘 Conclusion&lt;br&gt;
Hoisting is a fundamental concept in JavaScript that often surprises developers who are new to the language. By recognizing how the JavaScript engine handles declarations behind the scenes, developers can avoid common pitfalls and write more efficient code.&lt;/p&gt;

&lt;p&gt;Mentored and guided by &lt;a class="mentioned-user" href="https://dev.to/devsyncin"&gt;@devsyncin&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  JavaScript #HoistingInJavaScript #WebDevelopment #JavaScriptTips#DevSync #DevSyncBlog #FrontendDevelopment #LearnToCode#DevSync.in
&lt;/h1&gt;

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