A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/and-logical-operator-in-javascript/ below:

AND(&&) Logical Operator in JavaScript

AND(&&) Logical Operator in JavaScript

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.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4