Conditional (ternary) operator
Last updated
Was this helpful?
Last updated
Was this helpful?
The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is followed by a colon (:), and finally the expression to execute if the condition is . This operator is frequently used as a shortcut for the statement.
The conditional operator ?:, also known as the ternary conditional operator, evaluates a Boolean expression and returns the result of one of the two expressions, depending on whether the Boolean expression evaluates to true or false. Beginning with C# 7.2, the returns the reference to the result of one of the two expressions.