Why is 1 + 1 ? 1 : 0 + 1
equal to 1
and not 3
? It’s correct that it returns if I wrap the expression 1 ? 1 : 0
with parentheses. But why is that needed? What is actually blocking the process to parse it correctly?
>Solution :
Because js first calculate 1 + 1 and after that check RESULT is true? if it is true, select 1.
1+1 is the truthy result
The falsy values in JavaScript are 0, 0n, null, undefined, false, NaN, and the empty string ""