You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 12, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -611,7 +611,25 @@ If your editor/IDE isn't listed above, a list of available plugins can be found
611
611
612
612
**[⬆ back to top](#table-of-contents)**
613
613
614
+
## Ternary
614
615
616
+
- [Ternary operators](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) are fine so long as the statements are concise. Hint: If they need to span multiple lines you should use `if/else`.
617
+
618
+
```
619
+
// bad
620
+
age >18? (
621
+
alert("OK, you can go."),
622
+
location.assign("continue.html")
623
+
) : (
624
+
stop =true,
625
+
alert("Sorry, you are much too young!")
626
+
);
627
+
628
+
// good
629
+
age >18?location.assign("continue.html") : stop =true;
630
+
```
631
+
632
+
**[⬆ back to top](#table-of-contents)**
615
633
616
634
## Comparison Operators & Equality
617
635
@@ -1216,6 +1234,16 @@ If your editor/IDE isn't listed above, a list of available plugins can be found
1216
1234
this._firstName = 'Panda';
1217
1235
```
1218
1236
1237
+
- When defining a static/immutable `const` use uppercase
1238
+
1239
+
```
1240
+
// bad
1241
+
const timeoutDuration = 3000;
1242
+
1243
+
// good
1244
+
const TIMOUT_DURATION = 3000;
1245
+
```
1246
+
1219
1247
- When saving a reference to `this` use `self`, but prefer `bind` ([Bind on MDN] (https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind))
0 commit comments