File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -775,6 +775,26 @@ Other Style Guides
775
775
}
776
776
` ` `
777
777
778
+ <a name="functions--mutate-params"></a><a name="7.14"></a>
779
+ - [7.14](#functions--default-value-destructuring) Always use a default value for an argument when destructuring it.
780
+
781
+ > Why? Destructuring an undefined/null argument will result in an error.
782
+
783
+ ` ` ` javascript
784
+
785
+ // bad
786
+ function getFullName ({ firstName, lastName }) {
787
+ return ` ${ firstName} ${ lastName} ` ;
788
+ }
789
+
790
+ // good, defaults to an empty object
791
+ function getFullName ({ firstName, lastName } = {}) {
792
+ return ` ${ firstName} ${ lastName} ` ;
793
+ }
794
+ ` ` `
795
+
796
+
797
+
778
798
**[⬆ back to top](#table-of-contents)**
779
799
780
800
## Arrow Functions
You can’t perform that action at this time.
0 commit comments