Merge pull request #494 from johnmanong/default-parameters-last

Default parameters go last.
This commit is contained in:
Josh Perez
2015-08-31 15:34:46 -07:00

View File

@@ -556,7 +556,7 @@ Other Style Guides
}
```
- [7.8](#7.8) <a name='7.8'></a> Avoid side effects with default parameters
- [7.8](#7.8) <a name='7.8'></a> Avoid side effects with default parameters.
> Why? They are confusing to reason about.
@@ -572,7 +572,21 @@ Other Style Guides
count(); // 3
```
- [7.9](#7.9) <a name='7.9'></a> Never use the Function constructor to create a new function.
- [7.9](#7.9) <a name='7.9'></a> Always put default parameters last.
```javascript
// bad
function handleThings(opts = {}, name) {
// ...
}
// good
function handleThings(name, opts = {}) {
// ...
}
```
- [7.10](#7.10) <a name='7.10'></a> Never use the Function constructor to create a new function.
> Why? Creating a function in this way evaluates a string similarly to eval(), which opens vulnerabilities.