1. Variable and Function names
1.1 Use intention-revealing names
Bad Code
JAVASCRIPT
Clean Code
JAVASCRIPT
1.2 Make your variable names easy to pronounce
Bad Code
JAVASCRIPT
Clean Code
JAVASCRIPT
2. Better Functions
2.1 Less arguments are better
Bad Code
JAVASCRIPT
Clean Code
JAVASCRIPT
2.2 Use Arrow Functions when they make code cleaner
Bad Code
JAVASCRIPT
Clean Code
JAVASCRIPT
2.3 Use Async await for asynchronous code
Bad Code
JAVASCRIPT
Clean Code
JAVASCRIPT
3. Comments
3.1 Noise comments are bad
Bad Code
JAVASCRIPT
3.2 If code is readable you don’t need comments
Bad Code
JAVASCRIPT
Clean Code
JAVASCRIPT
4. Other code guidelines
There are a lot more, that you can do to identify and avoid bad code.
Below is a list of some code smells and anti-patterns to avoid.
4.1 Remove Dead code
Dead code is just as bad as duplicate code. There's no reason to keep it in your codebase. If it's not being called, get rid of it!
Bad Code
JAVASCRIPT
Clean Code
JAVASCRIPT