### Learning Objectives
- Differentiate between block-scoped `let`/`const` and legacy function-scoped `var`.
- Understand JavaScript dynamic type coercion vs strict equality comparison (`==` vs `===`).
- Use template literals and arrow function syntax concisely.
- Unpack objects and arrays cleanly using destructuring assignment and spread (`...`) operators.
---
### Lexical Scope & Variable Hoisting
In ECMAScript 6 (ES6), `let` and `const` were introduced to enforce **Block Scope**, placing declared variables inside a Temporal Dead Zone (TDZ) prior to execution. This eliminates variable hoisting bugs historically caused by function-scoped `var`.
Important Terminology & Common Pitfalls
### Key Terminology
- **Temporal Dead Zone (TDZ)**: Time window between scope entry and variable initialization where accessing `let`/`const` throws a `ReferenceError`.
- **Strict Equality (`===`)**: Checks both value and type equality without implicit type coercion.
- **Spread Operator (`...`)**: Unpacks iterable collections into individual arguments or elements.
---
### Common Pitfalls
1. **Implicit Type Coercion**: Using `==` converts string `"5"` to number `5` implicitly (`"5" == 5` is true, but `"5" === 5` is false).
2. **Mutating `const` Reference Objects**: Declaring an object with `const` prevents reassignment of the variable reference, but DOES NOT freeze object property mutations.
💻 Ready to test your knowledge with code?
Solve the hands-on coding exercise in the interactive code editor.