Javascript Ternary/Conditional Operators
JavaScript Ternary/Conditional Operators
The condition is Boolean-value statement-
-
If condition is true, the first true value is evaluated
-
Otherwise the second false value is evaluated
-
Remember that an integer division by a zero results in an exception that terminate the program
The Syntax of Ternary/Conditional Operators is as follows:
Condition ? exp1 : exp2
Example1
Output
Example2
Output