Skip to content

Commit 68f8cf3

Browse files
README.md
Here i added TDZ inside the hoisting part eith 14.1.1
1 parent 0e2ef17 commit 68f8cf3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,6 +1908,22 @@ Other Style Guides
19081908
}
19091909
```
19101910
1911+
<a name="hoisting--Temporal--Dead--Zone"></a><a name="14.1.1"></a>
1912+
- [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.
1913+
```javascript
1914+
// TDZ: accessing before initialization → ReferenceError
1915+
{
1916+
// console.log(foo); // ReferenceError
1917+
// console.log(typeof foo); // ReferenceError
1918+
let foo = 2; // TDZ ends here
1919+
}
1920+
1921+
// var contrasts with TDZ: hoisted to undefined
1922+
{
1923+
console.log(bar); // undefined
1924+
var bar = 1;
1925+
}
1926+
```
19111927
<a name="hoisting--anon-expressions"></a><a name="14.2"></a>
19121928
- [14.2](#hoisting--anon-expressions) Anonymous function expressions hoist their variable name, but not the function assignment.
19131929

0 commit comments

Comments
 (0)