Changed "statement" to "expression" (#39564)
The ternary operator doesn't allow statements, just expressions.
This commit is contained in:
@ -9,7 +9,7 @@ forumTopicId: 301181
|
|||||||
<section id='description'>
|
<section id='description'>
|
||||||
The <dfn>conditional operator</dfn>, also called the <dfn>ternary operator</dfn>, can be used as a one line if-else expression.
|
The <dfn>conditional operator</dfn>, also called the <dfn>ternary operator</dfn>, can be used as a one line if-else expression.
|
||||||
The syntax is:
|
The syntax is:
|
||||||
<code>condition ? statement-if-true : statement-if-false;</code>
|
<code>condition ? expression-if-true : expression-if-false;</code>
|
||||||
The following function uses an if-else statement to check a condition:
|
The following function uses an if-else statement to check a condition:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
Reference in New Issue
Block a user