Steps to Reproduce:
Run the following snippets and see the results:
code | result | link |
---|---|---|
("0"&123) === "0" | true | here |
(123&"0") === "0" | false | here |
(""&123) === "" | true | here |
(123&"") === "" | false | here |
("1"|123) === "1" | true | here |
(false|"1") === "1" | false | here |
("2"|123) === "2" | true | here |
(false|"2") === "2" | false | here |
Expected Results:
Either all true, or all false.
Discussion:
This really depends on the design decision, but it should be consistent. That is:
- Either a boolean operation always cast the answer to a boolean; or
- it returns one of the operands
Right now, we return one of the operands when it's short-circuiting, but cast to a boolean when it's not.