From 68f8cf3e641ed0f1d28359309a9de7f3ba513ae1 Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Tue, 7 Oct 2025 23:13:26 +0530 Subject: [PATCH] README.md Here i added TDZ inside the hoisting part eith 14.1.1 --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 9a325a355b..6a3a902508 100644 --- a/README.md +++ b/README.md @@ -1908,6 +1908,22 @@ Other Style Guides } ``` + + - [14.1.1](#hoisting--Temporal--Dead--Zone) Temporal Dead Zone (TDZ) is the period from entering a scope until the exact line where a let, const, or class binding is initialized; accessing it during this window throws a ReferenceError, unlike var which is hoisted and reads as undefined before assignment. + ```javascript + // TDZ: accessing before initialization → ReferenceError + { + // console.log(foo); // ReferenceError + // console.log(typeof foo); // ReferenceError + let foo = 2; // TDZ ends here + } + + // var contrasts with TDZ: hoisted to undefined + { + console.log(bar); // undefined + var bar = 1; + } + ``` - [14.2](#hoisting--anon-expressions) Anonymous function expressions hoist their variable name, but not the function assignment.