Naming, Readability, and Common Pitfalls
Naming and readability guidelines; avoid shadowing, magic numbers, and mixed declarations.
Intro
Goal: Write readable code. Use clear names, avoid magic numbers, and be careful with shadowing.
- Descriptive names
- Constants for fixed values
- No accidental shadowing

Clear naming demo
Name variables for what they hold, not how they are used. Short but clear wins.
// Use descriptive names
// Avoid single letters or vague words
const itemCount = 3;
const unitPrice = 5;
const totalPrice = itemCount * unitPrice;
console.log("Items:", itemCount);
console.log("Unit price:", unitPrice);
console.log("Total price:", totalPrice);

All lessons in this course
- let, const, and avoiding var
- Block/Function/Module Scope and the TDZ
- Naming, Readability, and Common Pitfalls