@@ -738,13 +738,13 @@ Other Style Guides
738
738
739
739
` ` ` javascript
740
740
// bad
741
- function concatenateAllStrings () {
741
+ function concatenateAll () {
742
742
const args = Array .prototype .slice .call (arguments );
743
743
return args .join (' ' );
744
744
}
745
745
746
746
// good
747
- function concatenateAllStrings (... args ) {
747
+ function concatenateAll (... args ) {
748
748
return args .join (' ' );
749
749
}
750
750
` ` `
@@ -852,11 +852,6 @@ Other Style Guides
852
852
function f2(obj) {
853
853
const key = Object.prototype.hasOwnProperty.call(obj, 'key') ? obj.key : 1;
854
854
}
855
-
856
- // best
857
- function f2(obj) {
858
- const key = Object.hasOwn(obj, 'key') ? obj.key : 1;
859
- }
860
855
` ` `
861
856
862
857
< a name= " functions--reassign-params" >< / a>< a name= " 7.13" >< / a>
@@ -1198,7 +1193,8 @@ Other Style Guides
1198
1193
1199
1194
const luke = new Jedi ();
1200
1195
1201
- luke .jump ().setHeight (20 );
1196
+ luke .jump ()
1197
+ .setHeight (20 );
1202
1198
` ` `
1203
1199
1204
1200
<a name="constructors--tostring"></a><a name="9.4"></a>
@@ -1329,7 +1325,7 @@ Other Style Guides
1329
1325
` ` `
1330
1326
1331
1327
< a name= " modules--no-wildcard" >< / a>< a name= " 10.2" >< / a>
1332
- - [10.2 ](#modules-- no- wildcard) Do not use wildcard imports unless you have multiple named exports and want to import all of them as single object .
1328
+ - [10.2 ](#modules-- no- wildcard) Do not use wildcard imports.
1333
1329
1334
1330
> Why? This makes sure you have a single default export .
1335
1331
@@ -1791,6 +1787,7 @@ Other Style Guides
1791
1787
1792
1788
```javascript
1793
1789
// bad
1790
+
1794
1791
const array = [1, 2, 3];
1795
1792
let num = 1;
1796
1793
num++;
@@ -1807,6 +1804,7 @@ Other Style Guides
1807
1804
}
1808
1805
1809
1806
// good
1807
+
1810
1808
const array = [1, 2, 3];
1811
1809
let num = 1;
1812
1810
num += 1;
@@ -1846,6 +1844,7 @@ Other Style Guides
1846
1844
1847
1845
```javascript
1848
1846
// bad
1847
+
1849
1848
const some_unused_var = 42;
1850
1849
1851
1850
// Write-only variables are not considered as used.
@@ -1862,6 +1861,7 @@ Other Style Guides
1862
1861
}
1863
1862
1864
1863
// good
1864
+
1865
1865
function getXPlusY(x, y) {
1866
1866
return x + y;
1867
1867
}
@@ -2165,7 +2165,7 @@ Other Style Guides
2165
2165
const foo = a ? a : b;
2166
2166
const bar = c ? true : false;
2167
2167
const baz = c ? false : true;
2168
- const quux = ( a !== undefined && a !== null) ? a : b;
2168
+ const quux = a != null ? a : b;
2169
2169
2170
2170
// good
2171
2171
const foo = a || b;
@@ -2966,12 +2966,11 @@ Other Style Guides
2966
2966
? .xyzzy ;
2967
2967
2968
2968
// good
2969
- $
2970
- .ajax ({
2971
- method: ' POST' ,
2972
- url: ' https://airbnb.com/' ,
2973
- data: { name: ' John' },
2974
- })
2969
+ $ .ajax ({
2970
+ method: ' POST' ,
2971
+ url: ' https://airbnb.com/' ,
2972
+ data: { name: ' John' },
2973
+ })
2975
2974
.done (() => console .log (' Congratulations!' ))
2976
2975
.fail (() => console .log (' You have failed this city.' ));
2977
2976
` ` `
0 commit comments