I don't get logic behind it.
I guess anything that isn't TRUE counts as False.
damn, btw what 45 is, TRUE or False?
0, false, and empty string are false, whereas true, any string (including string 0 (join [0] >)), and pretty much everything else, is true.
I know the number 0 and the string 0 look the same, but they're different. Just remember, if it's a rectangle input, it's a string, and a circle input is a number.
good answer, thanks.
upd. wait, no, it gives 45 as result instead of true, lol.
The "right answer" to this question is that 45 isn't in the domain of AND, which is defined only for TRUE and FALSE as inputs. So your original example is just a domain error. In some languages (e.g., Logo) you'd get an error message.
and NaN
and null
and undefined
In JavaScript, if the first operand of &&
is falsey (0
, false
, ""
NaN
, null
, undefined
), that operand is returned and the second is unevaluated; otherwise, the second operand is evaluated and returned.
If the first operand of ||
is truthy, that operand is returned and the second is unevaluated; otherwise, the second operand is evaluated and returned.
Why is "45"
falsey? Does Snap! 9 internally not solely (hmm... where have I seen that word...) use JavaScript's &&
operator?
Got me. I wouldn't be surprised if it changed when AND and OR were hyperized.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.