File tree
Expand file treeCollapse file tree1 file changed
+25
-0
lines changed Expand file treeCollapse file tree1 file changed
+25
-0
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -598,6 +598,31 @@ var totalOutput = programmerOutput
|
598 | 598 | ```
|
599 | 599 | **[⬆ back to top](#table-of-contents)**
|
600 | 600 |
|
| 601 | +### Avoid negative conditionals |
| 602 | + |
| 603 | +**Bad:** |
| 604 | +```javascript |
| 605 | +function isDOMNodeNotPresent(node) { |
| 606 | +// ... |
| 607 | +} |
| 608 | + |
| 609 | +if (!isDOMNodeNotPresent(node)) { |
| 610 | +// ... |
| 611 | +} |
| 612 | +``` |
| 613 | + |
| 614 | +**Good**: |
| 615 | +```javascript |
| 616 | +function isDOMNodePresent(node) { |
| 617 | +// ... |
| 618 | +} |
| 619 | + |
| 620 | +if (isDOMNodePresent(node)) { |
| 621 | +// ... |
| 622 | +} |
| 623 | +``` |
| 624 | +**[⬆ back to top](#table-of-contents)** |
| 625 | + |
601 | 626 | ### Avoid conditionals
|
602 | 627 | This seems like an impossible task. Upon first hearing this, most people say,
|
603 | 628 | "how am I supposed to do anything without an `if` statement?" The answer is that
|
|
You can’t perform that action at this time.
0 commit comments