[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Logical_AND [Back]  [Original]

AND (&&) - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

AND (&&)

Baseline
Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

AND (&&) ( ) true true .

. .

In this article

const a = 3;
const b = -2;

console.log(a > 0 && b > 0);
// Expected output: false

js
expr1 && expr2

AND (&&) . .

true (truthy) . false (falsy) .

.

  • false;
  • null;
  • NaN;
  • 0;
  • ("" or '' or ``);
  • undefined.

AND .

js
result = "" && "foo"; // result  ""( ) 
result = 2 && 0; // result  0  
result = "foo" && 4; // result  4  .

&& , . NOT Boolean .

AND (short-circuit, ) . , false AND . .

.

(some falsy expression) && expr

(some falsy expression) , expr . expr .

.

js
function A() {
  console.log("called A");
  return false;
}
function B() {
  console.log("called B");
  return true;
}

console.log(A() && B());
//  A   "called A"   .
// &&  false   ( A false ) false  .
// AND       B .

AND OR , && || . ( ).

js
true || (false && false); // returns true
true && (false || false); // returns false
2 === 3 || (4 < 0 && 1 === 1); // returns false

AND

&&( AND) .

js
a1 = true && true; // t && t returns true
a2 = true && false; // t && f returns false
a3 = false && true; // f && t returns false
a4 = false && 3 === 4; // f && f returns false
a5 = "Cat" && "Dog"; // t && t returns "Dog"
a6 = false && "Cat"; // f && t returns false
a7 = "Cat" && false; // t && f returns false
a8 = "" && false; // f && f returns ""
a9 = false && ""; // f && f returns false

AND OR

js
bCondition1 && bCondition2;

.

js
!(!bCondition1 || !bCondition2);

OR AND

js
bCondition1 || bCondition2;

.

js
!(!bCondition1 && !bCondition2);

.

js
bCondition1 || (bCondition2 && bCondition3);

.

js
bCondition1 || bCondition2 && bCondition3;

Specification
ECMAScript 2027 LanguageSpecification
# prod-LogicalANDExpression


Web Proxy Viewer  |  New URL  |  Original Page