Back to Tools
JavaScript Formatting Guidelines
Indentation & Spacing
- Use consistent indentation (2 or 4 spaces)
- Add spaces around operators
- Space after keywords (if, for, while)
- No trailing whitespace
Code Structure
- One statement per line
- Use semicolons consistently
- Proper brace placement
- Meaningful variable names
Comments & Documentation
- Use JSDoc for function documentation
- Inline comments for complex logic
- Remove commented-out code
- Keep comments up to date
JavaScript Tools & Best Practices
Linting
Use ESLint or JSHint to catch errors and enforce coding standards.
Minification
Minify JavaScript for production to reduce file size and improve performance.
Error Handling
Use try-catch blocks and proper error handling for robust applications.
Modern Features
Use ES6+ features like arrow functions, const/let, and template literals.