Skip to content

Commit 39b6002

Browse files
committed
Merge pull request airbnb#494 from johnmanong/default-parameters-last
Default parameters go last.
2 parents 13d782f + eeed55c commit 39b6002

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ Other Style Guides
556556
}
557557
```
558558
559-
- [7.8](#7.8) <a name='7.8'></a> Avoid side effects with default parameters
559+
- [7.8](#7.8) <a name='7.8'></a> Avoid side effects with default parameters.
560560
561561
> Why? They are confusing to reason about.
562562
@@ -572,7 +572,21 @@ Other Style Guides
572572
count(); // 3
573573
```
574574
575-
- [7.9](#7.9) <a name='7.9'></a> Never use the Function constructor to create a new function.
575+
- [7.9](#7.9) <a name='7.9'></a> Always put default parameters last.
576+
577+
```javascript
578+
// bad
579+
function handleThings(opts = {}, name) {
580+
// ...
581+
}
582+
583+
// good
584+
function handleThings(name, opts = {}) {
585+
// ...
586+
}
587+
```
588+
589+
- [7.10](#7.10) <a name='7.10'></a> Never use the Function constructor to create a new function.
576590
577591
> Why? Creating a function in this way evaluates a string similarly to eval(), which opens vulnerabilities.
578592

0 commit comments

Comments
 (0)