{
  "id": 12117165,
  "title": "Understanding Hoisting in JavaScript: var, let, const, and Functions",
  "url": "https://urgent.news/2026/10/05/understanding-hoisting-in-javascript-var-let-const-and-functions",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-05T09:30:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ansh_sheladiya/understanding-hoisting-in-javascript-var-let-const-and-functions-3fi2"
  },
  "original_language": "en",
  "account": "JavaScript hoisting can be a tricky concept to grasp. It involves the JavaScript engine preparing the execution environment and registering declarations before the code is executed line by line. This is why a function declaration can be called even before its position in the source code.\n\nFor example, function greet() can be called right away, even though it appears below its declaration in the code. This is because function declarations are fully initialized during the creation phase, allowing them to be called before they appear in the code.\n\nOn the other hand, var variables exist before assignment but initially contain undefined value. This means that if you try to log a var variable before its declaration, it will display undefined.\n\nIn contrast, let and const declarations remain inaccessible in the beginning of the scope until execution reaches their declaration. This period is known as the Temporal Dead Zone or TDZ. If you attempt to access a let or const variable before its declaration, it will throw a ReferenceError.\n\nFunction expressions are different from function declarations. They follow the same variable declaration rules as let and const, meaning they cannot be used before initialization without causing an undefined or ReferenceError.\n\nTo better understand hoisting, it's essential to stop thinking of JavaScript physically moving declarations to the top of the file. Instead, consider the engine creating bindings before executing statements, with different declaration types receiving different initialization behavior.",
  "summary": "JavaScript hoisting is one of those concepts that looks simple at first but can cause confusing bugs when declarations appear to work before they are written. Understanding what the JavaScript engine does during the creation phase makes these behaviors much easier to predict. Hoisting affects variables, functions, and different declaration types in different ways. In this guide, we will break…",
  "key_points": [
    "JavaScript hoisting prepares declarations before code execution",
    "Function declarations initialized during creation phase",
    "Var variables contain undefined before assignment"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}