In simple words, what is the ?: (conditional, "ternary") operator and how can I use it?
?:
It's an if statement all on one line.
if statement
So
var x=1; (x == 1) ? y="true" : y="false"; alert(y);
The expression to be evaluated is in the ( )
( )
If it matches true, execute the code after the ?
?
If it matches false, execute the code after the :
: