It's not an if
statement, it's a ternary operator.
But fundamentally, yes, what's happening is that first this part is evaluted:
(a === 'xyz')
...and becomes true
or false
. Then this is done (let's assume true
):
'Example: ' + true
...resulting in:
'Example: true'
...then this is done:
'Example: true' ? 'A' : 'B'
...which gives us 'A'
because the string isn't blank, and so it's truthy.
This is because +
has a higher precedence than the ternary (? :
).