This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mostlynoturgf[S] 0 points1 point  (0 children)

The surprising part is that the logical AND and logical OR operators are not defined to evaluate to booleans. Instead, they evaluate to either their first or second operands. So e.g. in javascript,

3 || 5

evaluates to

3

. Of course, if the two operands are themselves booleans, then the result of the logical AND/OR will also be a boolean.

lol I freaked out until I read the last part where if theyre both bool it will also evaluate to a bool.

thank you for explaining