Ternary Operators and Assignment

Ternary operators, if not abused, can make code easier to follow once you grasp the concept. While normally used for assignment, they can also be used to control program flow. The keys to this are the condition, question mark and colon that identify the condition and results.


var foo = (some_condition) ? then_code : else_code;

REFERENCES:

Leave a Reply