Tagged articles
10 articles
Page 1 of 1
FunTester
FunTester
Oct 17, 2025 · Fundamentals

Why Does var Print 2 Twice? Unraveling JavaScript’s Function Scope and Hoisting

This article explains why a JavaScript function using var prints “2” twice, by detailing var’s function scope, variable hoisting, the compilation and execution phases, and contrasting the behavior with let and const, while offering practical coding recommendations to avoid common pitfalls.

JavaScriptVarconst
0 likes · 9 min read
Why Does var Print 2 Twice? Unraveling JavaScript’s Function Scope and Hoisting
JavaScript
JavaScript
Mar 2, 2025 · Frontend Development

Why ‘var’ Is Dangerous and How let/const Solve Its Pitfalls

This article examines why the traditional JavaScript var keyword should be avoided, explains the subtle pitfalls of its function scope, hoisting, and global leakage, and highlights the essential, often overlooked features of let and const—including temporal dead zone, true block scope, and immutability nuances.

JavaScriptVarconst
0 likes · 8 min read
Why ‘var’ Is Dangerous and How let/const Solve Its Pitfalls
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Sep 20, 2024 · Fundamentals

Understanding JavaScript Pre‑compilation and Hoisting

This article explains JavaScript's pre‑compilation process, including variable and function declaration hoisting, the creation of execution contexts, and the differences between var, let, and const, using several illustrative code examples to clarify how the engine resolves identifiers at runtime.

JavaScriptPre-compilationVariables
0 likes · 7 min read
Understanding JavaScript Pre‑compilation and Hoisting
php Courses
php Courses
Jul 5, 2023 · Frontend Development

Understanding var, let, and const in JavaScript

This article explains the differences between JavaScript's var, let, and const declarations, covering their scopes, hoisting behavior, and mutability, and provides clear code examples for each. It also highlights how const variables can still be modified when they hold objects or arrays, helping developers choose the right keyword for reliable code.

JavaScriptVarconst
0 likes · 5 min read
Understanding var, let, and const in JavaScript
Yuewen Frontend Team
Yuewen Frontend Team
Nov 5, 2018 · Frontend Development

Master JavaScript Execution Contexts and Call Stack: A Deep Dive

This article explains how JavaScript execution contexts and the call stack work, covering their types, creation and execution phases, this binding, lexical and variable environments, and includes code examples to illustrate these core concepts for developers.

Execution ContextLexical Environmentcall stack
0 likes · 13 min read
Master JavaScript Execution Contexts and Call Stack: A Deep Dive
Tencent IMWeb Frontend Team
Tencent IMWeb Frontend Team
Sep 3, 2017 · Frontend Development

Why Does let Appear Not to Be Hoisted? Unraveling JavaScript’s Variable Lifecycle

This article chronicles the author’s two‑month journey of understanding JavaScript’s let declaration, exploring its block scope, temporal dead zone, per‑iteration bindings, and the nuanced differences from var and function hoisting, while debunking common misconceptions with code examples and spec references.

Variable Scopees6frontend
0 likes · 10 min read
Why Does let Appear Not to Be Hoisted? Unraveling JavaScript’s Variable Lifecycle
21CTO
21CTO
Nov 15, 2015 · Frontend Development

Why JavaScript Function Declarations Behave Differently Than Expressions

This article explains the crucial differences between JavaScript function declarations and function expressions, how hoisting affects their availability, and why misunderstanding these concepts can lead to unexpected bugs in your code.

JavaScriptfrontendfunction-declaration
0 likes · 7 min read
Why JavaScript Function Declarations Behave Differently Than Expressions
Java High-Performance Architecture
Java High-Performance Architecture
Oct 13, 2015 · Frontend Development

Understanding JavaScript Hoisting: Why console.log(test) Returns Undefined

JavaScript executes code by first compiling function and var declarations within a scope, then running statements top‑to‑bottom, which explains why accessing a var‑declared variable before its assignment yields undefined while referencing an undeclared variable throws an error, as illustrated through detailed examples.

JavaScriptVarexecution
0 likes · 4 min read
Understanding JavaScript Hoisting: Why console.log(test) Returns Undefined