{"id":127890,"date":"2024-10-28T08:47:00","date_gmt":"2024-10-28T06:47:00","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=127890"},"modified":"2024-10-25T19:06:28","modified_gmt":"2024-10-25T16:06:28","slug":"javascript-hoisting-pitfalls-common-scoping-issues","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html","title":{"rendered":"JavaScript Hoisting Pitfalls: Common Scoping Issues"},"content":{"rendered":"<p>Hoisting in <a href=\"https:\/\/www.javacodegeeks.com\/2023\/10\/javascript-fundamentals-2023-a-complete-learning-journey.html\">JavaScript<\/a> is a unique mechanism that moves declarations to the top of the current scope (either function or global scope) during the compilation phase. This can lead to unexpected behaviors, especially if you\u2019re not fully familiar with how hoisting interacts with <code>var<\/code>, <code>let<\/code>, and <code>const<\/code>. In this article, we\u2019ll break down common pitfalls with hoisting, how variable scoping plays a role, and how to avoid issues.<\/p>\n<h2 class=\"wp-block-heading\">1. Understanding Hoisting<\/h2>\n<p>When JavaScript is run, it first scans for variable and function declarations, &#8220;hoisting&#8221; them to the top of the scope before any code is executed. This allows you to reference a variable or function before it appears in the code, but with a few catches:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Function Declarations<\/strong> are fully hoisted, meaning you can call a function before it\u2019s defined.<\/li>\n<li><strong>Variables Declared with <code>var<\/code><\/strong> are hoisted, but they\u2019re initialized with <code>undefined<\/code>, so they can be referenced, but using them before assignment can lead to unexpected results.<\/li>\n<li><strong>Variables Declared with <code>let<\/code> and <code>const<\/code><\/strong> are also hoisted, but they are not initialized. This creates a &#8220;<a href=\"https:\/\/stackoverflow.com\/questions\/33198849\/what-is-the-temporal-dead-zone\">Temporal Dead Zone<\/a>&#8221; (TDZ) from the start of the block until the line where they are defined.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">1.1 Example of Hoisting with <code>var<\/code>, <code>let<\/code>, and <code>const<\/code><\/h3>\n<pre class=\"brush:js\">\nconsole.log(a); \/\/ Output: undefined (var is hoisted and initialized)\nvar a = 5;\n\nconsole.log(b); \/\/ ReferenceError: Cannot access 'b' before initialization\nlet b = 10;\n\nconsole.log(c); \/\/ ReferenceError: Cannot access 'c' before initialization\nconst c = 15;\n<\/pre>\n<p>In this example, <code>a<\/code> is declared with <code>var<\/code> and hoisted, allowing it to be referenced, but with an initial value of <code>undefined<\/code>. <code>b<\/code> and <code>c<\/code>, however, are in the TDZ until they are assigned, causing an error if accessed early.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h2 class=\"wp-block-heading\">2. Common Pitfalls and How to Avoid Them<\/h2>\n<h3 class=\"wp-block-heading\">1. Using <code>var<\/code> in Loop Scopes<\/h3>\n<p>Variables declared with <code>var<\/code> inside loops do not have block scope, leading to unexpected behavior.<\/p>\n<pre class=\"brush:js\">\nfor (var i = 0; i &lt; 3; i++) {\n    setTimeout(() =&gt; console.log(i), 100);\n}\n\/\/ Output: 3, 3, 3\n<\/pre>\n<p><strong>Solution:<\/strong> Use <code>let<\/code> instead to ensure block scoping.<\/p>\n<pre class=\"brush:js\">\nfor (let i = 0; i &lt; 3; i++) {\n    setTimeout(() =&gt; console.log(i), 100);\n}\n\/\/ Output: 0, 1, 2\n<\/pre>\n<h3 class=\"wp-block-heading\">2. Reference Errors with <code>let<\/code> and <code>const<\/code><\/h3>\n<p>Since <code>let<\/code> and <code>const<\/code> are in the TDZ until their declaration, referencing them before they\u2019re assigned causes a <code>ReferenceError<\/code>. Avoid accessing variables before they\u2019re declared.<\/p>\n<pre class=\"brush:js\">\nfunction test() {\n    console.log(x); \/\/ ReferenceError\n    let x = 5;\n}\n<\/pre>\n<p><strong>Solution:<\/strong> Declare <code>let<\/code> and <code>const<\/code> variables at the top of their block.<\/p>\n<h3 class=\"wp-block-heading\">3. Re-declaration with <code>var<\/code><\/h3>\n<p>Hoisting allows <code>var<\/code> declarations to be redeclared without errors, which can lead to bugs, especially in large codebases.<\/p>\n<pre class=\"brush:js\">\nvar name = \"Alice\";\nvar name = \"Bob\"; \/\/ No error, but can be a bug\n<\/pre>\n<p><strong>Solution:<\/strong> Use <code>let<\/code> or <code>const<\/code> for unique declarations to avoid accidental reassignments. <code>let<\/code> and <code>const<\/code> will throw an error if you try to redeclare them.<\/p>\n<h2 class=\"wp-block-heading\">3. Hoisting with Functions<\/h2>\n<p>Function declarations are fully hoisted, so they can be called before they are defined.<\/p>\n<pre class=\"brush:js\">\ngreet();\n\nfunction greet() {\n    console.log(\"Hello!\");\n}\n\/\/ Output: \"Hello!\"\n<\/pre>\n<p>However, <strong>function expressions<\/strong> (such as <code>const greet = function() {...}<\/code>) do not get fully hoisted. Only the variable is hoisted (in this case, <code>const greet<\/code>), not the assignment. Calling a function expression before its declaration will cause a <code>ReferenceError<\/code>.<\/p>\n<pre class=\"brush:js\">\nconsole.log(greet); \/\/ ReferenceError\nconst greet = function() {\n    console.log(\"Hello!\");\n};\n<\/pre>\n<h2 class=\"wp-block-heading\">4. Hoisting in Nested Scopes<\/h2>\n<p>Variables declared within nested functions follow function scope. Hoisting applies only within their specific function scope, not globally.<\/p>\n<pre class=\"brush:js\">\nfunction outer() {\n    function inner() {\n        console.log(a); \/\/ undefined, since a is hoisted within inner's scope\n        var a = 10;\n    }\n    inner();\n    console.log(a); \/\/ ReferenceError, a is not defined in outer\n}\nouter();\n<\/pre>\n<h2 class=\"wp-block-heading\">5. Summary: Best Practices for Avoiding Hoisting Pitfalls<\/h2>\n<p>In summary, hoisting in JavaScript can lead to confusing behaviors, particularly with <code>var<\/code>, <code>let<\/code>, and <code>const<\/code>. To avoid common pitfalls, it\u2019s best to use <code>let<\/code> and <code>const<\/code> over <code>var<\/code> since they enforce block scoping and avoid issues like redeclaration and temporal dead zones (TDZ). Placing all variable declarations at the top of their scope helps prevent errors with <code>let<\/code> and <code>const<\/code>. When it comes to functions, use function declarations if they need to be accessible before their definition, while function expressions are better suited for situations where hoisting isn\u2019t required.<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hoisting in JavaScript is a unique mechanism that moves declarations to the top of the current scope (either function or global scope) during the compilation phase. This can lead to unexpected behaviors, especially if you\u2019re not fully familiar with how hoisting interacts with var, let, and const. In this article, we\u2019ll break down common pitfalls &hellip;<\/p>\n","protected":false},"author":1010,"featured_media":20900,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1879],"tags":[2578,803,3136],"class_list":["post-127890","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-hoisting","tag-javascript","tag-pitfalls"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript Hoisting Pitfalls: Common Scoping Issues - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Learn how JavaScript hoisting works, common pitfalls with var, let, and const, and best practices to avoid scoping issues.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Hoisting Pitfalls: Common Scoping Issues - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Learn how JavaScript hoisting works, common pitfalls with var, let, and const, and best practices to avoid scoping issues.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-28T06:47:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Eleftheria Drosopoulou\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Eleftheria Drosopoulou\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html\"},\"author\":{\"name\":\"Eleftheria Drosopoulou\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5fe56fff01ece0694747967c7217bca4\"},\"headline\":\"JavaScript Hoisting Pitfalls: Common Scoping Issues\",\"datePublished\":\"2024-10-28T06:47:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html\"},\"wordCount\":503,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"keywords\":[\"Hoisting\",\"JavaScript\",\"Pitfalls\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html\",\"name\":\"JavaScript Hoisting Pitfalls: Common Scoping Issues - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"datePublished\":\"2024-10-28T06:47:00+00:00\",\"description\":\"Learn how JavaScript hoisting works, common pitfalls with var, let, and const, and best practices to avoid scoping issues.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2024\\\/10\\\/javascript-hoisting-pitfalls-common-scoping-issues.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\\\/javascript\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"JavaScript Hoisting Pitfalls: Common Scoping Issues\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5fe56fff01ece0694747967c7217bca4\",\"name\":\"Eleftheria Drosopoulou\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/Eleftheria-Drosopoulou-96x96.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/Eleftheria-Drosopoulou-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/Eleftheria-Drosopoulou-96x96.jpg\",\"caption\":\"Eleftheria Drosopoulou\"},\"description\":\"Eleftheria is an Experienced Business Analyst with a robust background in the computer software industry. Proficient in Computer Software Training, Digital Marketing, HTML Scripting, and Microsoft Office, they bring a wealth of technical skills to the table. Additionally, she has a love for writing articles on various tech subjects, showcasing a talent for translating complex concepts into accessible content.\",\"sameAs\":[\"http:\\\/\\\/www.javacodegeeks.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/eleftheria-drosopoulou\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Hoisting Pitfalls: Common Scoping Issues - Java Code Geeks","description":"Learn how JavaScript hoisting works, common pitfalls with var, let, and const, and best practices to avoid scoping issues.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html","og_locale":"en_US","og_type":"article","og_title":"JavaScript Hoisting Pitfalls: Common Scoping Issues - Java Code Geeks","og_description":"Learn how JavaScript hoisting works, common pitfalls with var, let, and const, and best practices to avoid scoping issues.","og_url":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2024-10-28T06:47:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","type":"image\/jpeg"}],"author":"Eleftheria Drosopoulou","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Eleftheria Drosopoulou","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html"},"author":{"name":"Eleftheria Drosopoulou","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5fe56fff01ece0694747967c7217bca4"},"headline":"JavaScript Hoisting Pitfalls: Common Scoping Issues","datePublished":"2024-10-28T06:47:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html"},"wordCount":503,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","keywords":["Hoisting","JavaScript","Pitfalls"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html","url":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html","name":"JavaScript Hoisting Pitfalls: Common Scoping Issues - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","datePublished":"2024-10-28T06:47:00+00:00","description":"Learn how JavaScript hoisting works, common pitfalls with var, let, and const, and best practices to avoid scoping issues.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2024\/10\/javascript-hoisting-pitfalls-common-scoping-issues.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/www.javacodegeeks.com\/category\/web-development"},{"@type":"ListItem","position":3,"name":"JavaScript","item":"https:\/\/www.javacodegeeks.com\/category\/web-development\/javascript"},{"@type":"ListItem","position":4,"name":"JavaScript Hoisting Pitfalls: Common Scoping Issues"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5fe56fff01ece0694747967c7217bca4","name":"Eleftheria Drosopoulou","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/Eleftheria-Drosopoulou-96x96.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/Eleftheria-Drosopoulou-96x96.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/Eleftheria-Drosopoulou-96x96.jpg","caption":"Eleftheria Drosopoulou"},"description":"Eleftheria is an Experienced Business Analyst with a robust background in the computer software industry. Proficient in Computer Software Training, Digital Marketing, HTML Scripting, and Microsoft Office, they bring a wealth of technical skills to the table. Additionally, she has a love for writing articles on various tech subjects, showcasing a talent for translating complex concepts into accessible content.","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/eleftheria-drosopoulou"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/127890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/1010"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=127890"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/127890\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/20900"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=127890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=127890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=127890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}