File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments