I recently wrote code that didnt work as i would expect, it was:
message = 'Thank You';
type = 'success';
message = message || type == 'success' ? 'Success' : 'Error';
It was news to me that at the end of that message was set to ‘Success’.
I would think that since the truthy value of message is true, the right side of the or would not evaluate.
Parenthesis around the right side of the OR solved this, but i still dont understand why the right side was evaluated at all
Your code is equivalent to
That’s why. 🙂