The ||
operator returns the left hand side if the left hand side is true, otherwise it returns the right hand side.
Thus (false || "test")
is "test"
.
"test"
is a true value, so you get:
"test" ? "first" : "second"
The ternary operator returns the value before the :
if the value before the ?
is a true value (which is is).
What happens in general when the conditional operator can't evaluate an expression as True or False ?
The result of any expression can be evaluated as being a true or false value, so that will never happen.