Open links in new tab
    • Work Report
    • Email
    • Rewrite
    • Speech
    • Title Generator
    • Smart Reply
    • Poem
    • Essay
    • Joke
    • Instagram Post
    • X Post
    • Facebook Post
    • Story
    • Cover Letter
    • Resume
    • Job Description
    • Recommendation Letter
    • Resignation Letter
    • Invitation Letter
    • Greeting Message
    • Try more templates
  1. In JavaScript, hoisting is the behavior where declarations (not initializations) are moved to the top of their scope during the compilation phase, before code execution. This applies to both the global scope and function scope.

    Function Declarations are fully hoisted — both the name and implementation are moved to the top. This allows calling a function before it appears in the code.

    sayHi("Rahul");
    sum(1, 2);

    function sayHi(name) {
    console.log(name);
    }

    function sum(a, b) {
    console.log(a + b);
    }
    Copied!

    Here, both functions work even though they are called before their definitions.

    Variables with var are hoisted and initialized to undefined at the top of their scope. Accessing them before assignment returns undefined.

    console.log(x); // undefined
    var x = 5;
    Copied!

    Variables with let and const are also hoisted but remain uninitialized in the Temporal Dead Zone (TDZ) until their declaration line is executed. Accessing them before initialization throws a ReferenceError.

    console.log(a); // ReferenceError
    let a = 10;
    Copied!
    Feedback
  2. JavaScript Hoisting - W3Schools

    Hoisting is (to many developers) an unknown or overlooked behavior of JavaScript. If a developer doesn't understand hoisting, programs may contain bugs (errors). To avoid …
    Javascript Declarations Are Hoisted

    In JavaScript, a variable can be declared after it has been used. In other words; a variable can be used before it has been declared. Example 1 gives the same result as Example 2: To understand this, you have to understand the term "hoisting". Hoistin…

    The Let and Const Keywords

    Variables defined with let and const are hoisted to the top of the block, but not initialized. Meaning: The block of code is aware of the variable, but it cannot be used until it has been declared. Using a let variable before it is declared will result in …

  3. JavaScript Hoisting - GeeksforGeeks

    Jan 15, 2026 · Hoisting refers to the behavior where JavaScript moves the declarations of variables, functions, and classes to the top of their scope during …

  4. Hoisting - Glossary | MDN

    Jul 11, 2025 · JavaScript Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables, classes, or imports to the top of their scope, prior to execution of …

  5. JavaScript Hoisting Explained By Examples

    In this tutorial, you'll learn how about the JavaScript hoisting and how it works under the hood.

  6. JavaScript Hoisting (with Examples) - Programiz

    In JavaScript, hoisting is a behavior in which a function or a variable can be used before declaration. In this tutorial, you will learn about JavaScript hoisting with the help of examples.

  7. JavaScript Hoisting Explained: A Beginner’s Guide with …

    Sep 24, 2025 · What Is Hoisting in JavaScript? Hoisting is the process by which JavaScript moves all declarations (not assignments) to the top of the current …

  8. Master Hoisting in JavaScript with 5 Examples

    Feb 21, 2026 · Code snippet examples which will help to grasp the concept of Hoisting in JavaScript, with solutions to understand how it works behind the scene.

  9. JavaScript Hoisting - Tutorial Republic

    In JavaScript, all functions and variables (only variables declared with the var keyword) declarations are moved or hoisted to the top of their current scope, regardless of where it is defined. This is the default …

  10. Scope, Closures, and Hoisting in JavaScript – Explained …

    Jun 26, 2024 · In this comprehensive guide, we will delve deep into the realms of scope, closures, and hoisting in JavaScript, unraveling their complexities, …

  11. Understanding JavaScript Scope and Hoisting - w3tutorials.net

    Scope determines where variables and functions can be accessed, while hoisting affects how JavaScript code is interpreted and executed. In this blog post, we will explore these two concepts in …