File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -98,15 +98,13 @@ details on which values evaluate to true and which evaluate to false.
98
98
You'll sometimes see developers use these logical operators for flow control
99
99
instead of using if statements. For example:
100
100
101
- <div class =" example " markdown =" 1 " >
102
- // do something with foo if foo is truthy
103
- foo && doSomething(foo);
101
+ // do something with foo if foo is truthy
102
+ foo && doSomething(foo);
104
103
105
- // set bar to baz if baz is truthy;
106
- // otherwise, set it to the return
107
- // value of createBar()
108
- var bar = baz || createBar();
109
- </div >
104
+ // set bar to baz if baz is truthy;
105
+ // otherwise, set it to the return
106
+ // value of createBar()
107
+ var bar = baz || createBar();
110
108
111
109
This style is quite elegant and pleasantly terse; that said, it can be really
112
110
hard to read, especially for beginners. I bring it up here so you'll recognize
You can’t perform that action at this time.
0 commit comments