mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-11 13:18:00 -05:00
return when it makes sense. fixes #9
This commit is contained in:
26
README.md
26
README.md
@@ -264,32 +264,6 @@
|
||||
}
|
||||
```
|
||||
|
||||
- Always return as early as possible
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
function() {
|
||||
var size;
|
||||
|
||||
if (!arguments.length) {
|
||||
size = false;
|
||||
} else {
|
||||
size = arguments.length;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
// good
|
||||
function() {
|
||||
if (!arguments.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return arguments.length;
|
||||
}
|
||||
```
|
||||
|
||||
- Never name a parameter `arguments`, this will take precendence over the `arguments` object that is given to every function scope.
|
||||
|
||||
```javascript
|
||||
|
||||
Reference in New Issue
Block a user