Description

If the value of test is non-empty ("true"), then: if the value of then is defined, that value is produced, otherwise the empty string.

If the value of test is empty ("false"), then: if the value of else is defined, that value is produced, otherwise the empty string.

If the value of test is undefined:

if the value of else is defined, that value is produced.

if the value of else is also undefined, then: if the value of then is defined, that value is produced, otherwise the empty string.

Note that the rules for the case that the value of test is undefined are somewhat arbitrary, and just a by-product of the code. Note in particular that in this case it makes a difference whether the value of else is empty or undefined, see the examples below.