Device Monitoring Studio - Monitor, log and analyze data coming through PC ports and connections
Download Device Monitoring Studio Hide this button

?: Conditional Operator

This is the only supported ternary operator. It evaluates to the value of its second operand if the first operand evaluates to non-zero value, otherwise, it evaluates to the value of the third operand.

Syntax:

exp1 ? exp2 : exp3

Usage:

5 == 3 ? 8 : 7               // evaluates to 7
2 == 2 ? 8 : 7               // evaluates to 8