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

(&&=) - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

(&&=)

Baseline

20209

(&&=)

let a = 1;
let b = 0;

a &&= 2;
console.log(a);
// : 2

b &&= 2;
console.log(b);
// : 0

js
x &&= y

x &&= y x && (x = y) x

x const

js
const x = 0;
x &&= 2;

js
const x = {
  get value() {
    return 0;
  },
  set value(v) {
    console.log("");
  },
};

x.value &&= 2;

x y

js
const x = 0;
x &&= console.log("y ");
// 

js
let x = 0;
let y = 1;

x &&= 0; // 0
x &&= 1; // 0
y &&= 1; // 1
y &&= 0; // 0

ECMAScript 2027 LanguageSpecification
# sec-assignment-operators


Web Proxy Viewer  |  New URL  |  Original Page