<?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: Pranav Tech</title>
    <description>The latest articles on DEV Community by Pranav Tech (@pranavtech).</description>
    <link>https://dev.to/pranavtech</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%2F2634614%2F2ca52a40-d33d-4406-b6f9-c98d51c25108.jpg</url>
      <title>DEV Community: Pranav Tech</title>
      <link>https://dev.to/pranavtech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pranavtech"/>
    <language>en</language>
    <item>
      <title>Comprehensive JavaScript Study Plan (80-20 Rule)</title>
      <dc:creator>Pranav Tech</dc:creator>
      <pubDate>Mon, 27 Jan 2025 15:28:25 +0000</pubDate>
      <link>https://dev.to/pranavtech/comprehensive-javascript-study-plan-80-20-rule-2le2</link>
      <guid>https://dev.to/pranavtech/comprehensive-javascript-study-plan-80-20-rule-2le2</guid>
      <description>&lt;p&gt;Focus on the &lt;em&gt;20% of concepts that power 80% of real-world projects&lt;/em&gt;. Master these fundamentals first, then expand through projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Core Learning (2 Weeks)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Daily Structure&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Morning&lt;/strong&gt;: Study concepts (1–2 hours).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Afternoon&lt;/strong&gt;: Practice exercises (1–2 hours).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evening&lt;/strong&gt;: Reflect, debug, and review (30 mins).
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Week 1: Foundations&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Day 1: Basics&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Variables (&lt;code&gt;let&lt;/code&gt;, &lt;code&gt;const&lt;/code&gt;), data types (strings, numbers, booleans), operators (&lt;code&gt;+&lt;/code&gt;, &lt;code&gt;===&lt;/code&gt;, &lt;code&gt;!&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: MDN JavaScript Basics, freeCodeCamp’s JS Syntax course.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Write code to calculate BMI or convert Celsius to Fahrenheit.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 2: Control Flow&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Conditionals (&lt;code&gt;if/else&lt;/code&gt;, &lt;code&gt;switch&lt;/code&gt;), loops (&lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: JavaScript.info Conditionals and Loops.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Solve FizzBuzz, print prime numbers.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 3: Functions&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Function declarations, parameters, &lt;code&gt;return&lt;/code&gt;, arrow functions, scope.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: MDN Functions Guide.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Create a function to reverse a string or calculate factorials.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 4: DOM Manipulation&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Select elements (&lt;code&gt;querySelector&lt;/code&gt;), modify content (&lt;code&gt;textContent&lt;/code&gt;, &lt;code&gt;innerHTML&lt;/code&gt;), styles (&lt;code&gt;classList&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: freeCodeCamp DOM Manipulation Tutorial.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Build a button that changes page background color.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 5: Events&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Event listeners (&lt;code&gt;click&lt;/code&gt;, &lt;code&gt;submit&lt;/code&gt;), event objects, &lt;code&gt;preventDefault()&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: JavaScript.info Introduction to Events.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Create a toggle button for dark/light mode.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 6: Arrays&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Array methods (&lt;code&gt;push&lt;/code&gt;, &lt;code&gt;pop&lt;/code&gt;, &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt;, &lt;code&gt;forEach&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: MDN Array Guide.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Filter even numbers from an array or sort names alphabetically.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 7: Review &amp;amp; Mini-Project&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Review&lt;/strong&gt;: Rebuild earlier exercises without referencing code.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mini-Project&lt;/strong&gt;: Simple counter app (increment/decrement buttons).
&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;Week 2: Intermediate Concepts&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Day 8: Objects&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Object literals, methods, &lt;code&gt;this&lt;/code&gt; keyword, destructuring.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: JavaScript.info Objects Basics.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Create a &lt;code&gt;user&lt;/code&gt; object with methods to update profile data.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 9: Asynchronous JS&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Callbacks, promises, &lt;code&gt;async/await&lt;/code&gt;, &lt;code&gt;fetch()&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: MDN Asynchronous JavaScript.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Fetch data from JSONPlaceholder API and display titles.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 10: Error Handling&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: &lt;code&gt;try/catch&lt;/code&gt;, throwing errors, debugging with &lt;code&gt;console&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: JavaScript.info Error Handling.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Add error handling to your API fetch code.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 11: ES6+ Features&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Template literals, spread/rest operators, modules (&lt;code&gt;import/export&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: ES6 for Everyone (free course).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Refactor old code using ES6 syntax.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 12: Local Storage&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: &lt;code&gt;localStorage&lt;/code&gt;, &lt;code&gt;JSON.stringify()&lt;/code&gt;, &lt;code&gt;JSON.parse()&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: MDN Web Storage API.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Save and retrieve user preferences (e.g., dark mode).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 13: Closures &amp;amp; Callbacks&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topics&lt;/strong&gt;: Lexical scope, closure examples, higher-order functions.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: MDN Closures.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Create a function factory (e.g., multiplier functions).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Day 14: Final Review &amp;amp; Prep for Projects&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Review&lt;/strong&gt;: Build a small app combining DOM, events, and localStorage.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prep&lt;/strong&gt;: Set up a project folder with HTML/CSS/JS files.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;5 Projects to Apply &amp;amp; Expand Knowledge&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Build these &lt;strong&gt;in order&lt;/strong&gt;, increasing complexity and autonomy. Use documentation and Google to solve roadblocks.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. To-Do List (Beginner)&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: Add, delete, and mark tasks as complete.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key Concepts&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;DOM manipulation (rendering tasks dynamically).
&lt;/li&gt;
&lt;li&gt;Event handling (form submission, click events).
&lt;/li&gt;
&lt;li&gt;Array methods (&lt;code&gt;filter&lt;/code&gt; for deleting tasks).
&lt;/li&gt;
&lt;li&gt;Local storage (persist tasks on reload).
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;2. Weather App (Intermediate)&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: Fetch real-time weather data from an API (e.g., OpenWeatherMap).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key Concepts&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;fetch()&lt;/code&gt; and async/await.
&lt;/li&gt;
&lt;li&gt;Working with JSON data.
&lt;/li&gt;
&lt;li&gt;Error handling for API failures.
&lt;/li&gt;
&lt;li&gt;Dynamic DOM updates based on user input (city search).
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;3. Quiz Game (Intermediate+)&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: Timed quiz with multiple-choice questions and a scoreboard.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key Concepts&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Object-oriented design (quiz and question classes).
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setInterval&lt;/code&gt; for timers.
&lt;/li&gt;
&lt;li&gt;State management (tracking current question, score).
&lt;/li&gt;
&lt;li&gt;Event delegation for answer buttons.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;4. Budget Tracker (Advanced)&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: Track income/expenses with charts (use Chart.js).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key Concepts&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Complex state (transactions, balance, categories).
&lt;/li&gt;
&lt;li&gt;Integration with third-party libraries (Chart.js).
&lt;/li&gt;
&lt;li&gt;Form validation and error feedback.
&lt;/li&gt;
&lt;li&gt;Local storage for data persistence.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;5. Full-Stack Bookstore (Advanced+)&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: CRUD app with a Node.js/Express backend and vanilla JS frontend.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key Concepts&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;REST API design (GET, POST, DELETE).
&lt;/li&gt;
&lt;li&gt;Advanced async operations (frontend-backend communication).
&lt;/li&gt;
&lt;li&gt;Modular code (separate API service module).
&lt;/li&gt;
&lt;li&gt;Deployment basics (DigitalOcean, Netlify).
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Tips for Success&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Code Daily&lt;/strong&gt;: Even 30 minutes reinforces muscle memory.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Break Problems Down&lt;/strong&gt;: Use pseudocode to plan projects step-by-step.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embrace Debugging&lt;/strong&gt;: Learn to use &lt;code&gt;console.log()&lt;/code&gt; and Chrome DevTools.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Refactor Ruthlessly&lt;/strong&gt;: Improve code readability and efficiency after getting it working.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This plan balances structured learning with creative problem-solving. Start small, iterate often, and celebrate progress! 🚀&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Javascript Hoisting</title>
      <dc:creator>Pranav Tech</dc:creator>
      <pubDate>Sun, 12 Jan 2025 07:00:52 +0000</pubDate>
      <link>https://dev.to/pranavtech/javascript-hoisting-22oi</link>
      <guid>https://dev.to/pranavtech/javascript-hoisting-22oi</guid>
      <description>&lt;p&gt;In JavaScript, you can use a variable before declaring it. This is called "hoisting". The declaration is moved to the top, so the variable is recognized even if it's used earlier.&lt;/p&gt;

&lt;p&gt;In JavaScript, there are two types of hoisting:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Function Hoisting&lt;/strong&gt;: Functions declared using the &lt;code&gt;function&lt;/code&gt; keyword are "hoisted" to the top of their scope, allowing them to be called before they're defined.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Variable Hoisting&lt;/strong&gt;: Variables declared using &lt;code&gt;var&lt;/code&gt; are also "hoisted" to the top of their scope, but only the declaration is hoisted, not the assignment.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; variables are not hoisted in the same way as &lt;code&gt;var&lt;/code&gt; variables. They are still hoisted, but they are not initialized until they are declared, so trying to access them before they are declared will result in a ReferenceError.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Function hoisting in JavaScript only works for:&lt;br&gt;
&lt;strong&gt;Function declarations&lt;/strong&gt;: Functions declared using the &lt;code&gt;function&lt;/code&gt; keyword, like this: &lt;code&gt;function myFunction() { ... }&lt;/code&gt;&lt;br&gt;
It does &lt;strong&gt;not&lt;/strong&gt; work for:&lt;br&gt;
&lt;strong&gt;Function expressions&lt;/strong&gt;: Functions assigned to a variable, like this: &lt;code&gt;var myFunction = function() { ... }&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Arrow functions&lt;/strong&gt;: Functions declared using the arrow syntax, like this: &lt;code&gt;var myFunction = () =&amp;gt; { ... }&lt;/code&gt;&lt;br&gt;
&lt;em&gt;So, only plain function declarations are hoisted in JavaScript.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Variabel Hoisting Example:&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="c1"&gt;// Using the variable before declaring it&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Output: undefined&lt;/span&gt;

&lt;span class="c1"&gt;// Declaring the variable&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, even though &lt;code&gt;x&lt;/code&gt; is used before it's declared, the code doesn't throw an error. Instead, &lt;code&gt;x&lt;/code&gt; is logged as &lt;code&gt;undefined&lt;/code&gt;. This is because the variable declaration is &lt;strong&gt;hoisted&lt;/strong&gt; to the top.&lt;/p&gt;

&lt;p&gt;Function Hoisting Example:&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="c1"&gt;// Calling the function before it's declared&lt;/span&gt;
&lt;span class="nf"&gt;myFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Declaring the function&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;myFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, world!&lt;/span&gt;&lt;span class="dl"&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;// Output: "Hello, world!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, even though we call &lt;code&gt;myFunction()&lt;/code&gt; before it's declared, the code still works because the function declaration is "hoisted" to the top of the scope.&lt;/p&gt;

&lt;p&gt;then give me "Could include a quick "best practices" section" for it&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices for Handling Hoisting in JavaScript
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Declare Variables at the Top&lt;/li&gt;
&lt;li&gt;Always declare variables at the beginning of their scope&lt;/li&gt;
&lt;li&gt;Improves code readability&lt;/li&gt;
&lt;li&gt;Prevents unexpected behavior from hoisting
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Recommended approach&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Rest of your code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Prefer &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; Over &lt;code&gt;var&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; for more predictable variable behavior&lt;/li&gt;
&lt;li&gt;They have block scope and aren't hoisted in the same way as &lt;code&gt;var&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Helps prevent unintended variable access
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Recommended&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MAX_SIZE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Avoid&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;unpredictableVariable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Avoid Relying on Hoisting&lt;/li&gt;
&lt;li&gt;Don't write code that depends on hoisting mechanics&lt;/li&gt;
&lt;li&gt;Declare functions and variables before using them&lt;/li&gt;
&lt;li&gt;Makes your code more explicit and easier to understand
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Good: Clear and predictable&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Function logic&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Avoid: Relies on hoisting&lt;/span&gt;
&lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Risky&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Function logic&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Use Strict Mode&lt;/li&gt;
&lt;li&gt;Enable &lt;code&gt;'use strict'&lt;/code&gt; to catch potential hoisting-related errors&lt;/li&gt;
&lt;li&gt;Helps identify and prevent problematic code patterns
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Strict mode will throw errors for certain hoisting scenarios&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Be Consistent with Function Declarations&lt;/li&gt;
&lt;li&gt;Stick to function declarations for better predictability&lt;/li&gt;
&lt;li&gt;Avoid mixing function declaration and expression styles
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Consistent and clear&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;mainFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;helperFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Logic&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;blockquote&gt;
&lt;p&gt;Pro Tips&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always aim for code clarity&lt;/li&gt;
&lt;li&gt;Understand hoisting, but don't rely on it as a coding technique&lt;/li&gt;
&lt;li&gt;Write code that is self-explanatory and predictable&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

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