/

HTML / CSS / JavaScript Tutorial

JavaScript Operator: conditional

[this page | pdf | back links]

In JavaScript, the conditional operator is the (ternary) operator that selects between two possible expressions to evaluate depending on whether an expression is true or false.

 

For example, var3 = (boolval) ? var1 : var2 results in var3 being set equal to var1 if boolval is true, otherwise var3 is set equal to var2.

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Operators


Desktop view | Switch to Mobile