AND(&&) Logical Operator in JavaScript (original) (raw)

Last Updated : 05 Jun, 2024

The **logical AND (&&) (logical conjunction) operator for a set of boolean operands will be true if and only if all the operands are true. Otherwise, it will be false. It's commonly used to combine conditions in conditional statements or to check multiple conditions before executing code.

The Logical AND(&&) Operator can also be used on non-boolean values also. AND operator has higher precedence than the OR operator.

**Syntax:

a&&b

**Example 1: In this example, we will use the AND operator on normal values.

JavaScript `

console.log(true && false); console.log(true && true); console.log(1 && 0); console.log(1 && 2); console.log("1" && true); console.log("0" && true);

`

**Output:

false
true
0
2
true
true

**Example 2: In this example, we will use the AND operator on function calls

JavaScript `

function a () { return true; } function b () { return true; }

console.log(a() && b());

`

**Output:

true

**Supported Browsers:

We have a complete list of JavaScript Logical Operators, to learn about those please go through JavaScript Logical Operator article.