Skip to content

Commit 55d8b21

Browse files
Add conditionals rules
1 parent 856a4f2 commit 55d8b21

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

manual/en-US/coding-standards/chapters/javascript.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,26 @@ $('.someElement')
332332
```
333333
334334
### Hoisting
335+
## Conditional Statements
335336
336-
// TODO
337+
Use ternary syntax if:
337338
339+
- One condition
340+
- Result of either evaluation is one operation.
338341
339-
// TODO
342+
```
343+
joomlaRocks ? 'This is true' : 'else it is false';
344+
```
340345
341-
## Conditional Statements
346+
Otherwise, use standard syntax:
342347
343-
// TODO ternary/with braces
348+
```
349+
if ( condition ) {
350+
// statements
351+
} else {
352+
// statements
353+
}
354+
```
344355
345356
**Cache length in variable for performance:**
346357

0 commit comments

Comments
 (0)