Why the result of bool(true) && string is string in javascript?

javascript

Solution

From MDN (Logical Operators) - Logical And (&&):

Returns expr1 if it can be converted to false; otherwise, returns expr2. Thus, when used with Boolean values, && returns true if both operands are true; otherwise, returns false.

`true` obviously cannot be evaluated to false, so the second value is returned which is "abc".

Problem

test code is: ``` console.log(true && "abc");//abc ``` who can tell me why the result is `abc`?

Original source

Related problems