Ternary Operator
This lesson discusses ternary operators in detail including compound ternary expressions using examples.
We'll cover the following
Ternary Operator #
The ternary operator is a comparison operator that evaluates something based on a condition being true or not.
The ternary operator is shorthand syntax for
if-else
.
It allows to quickly test a condition and often
replaces a multi-line if
statement, making your code more compact.
Syntax #
Here’s the syntax: