Clean Code JavaScript – Comment Patterns
Table of Contents
- When to Comment
- When Not to Comment
- Examples
When to Comment
- Explain why, not what
- Document complex business rules
When Not to Comment
- Obvious code
- Outdated explanations
Examples
// ❌ Bad
// Increment i by 1
i++;
// ✅ Good
// Retry once to handle flaky network condition
retryRequest();