Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年9月.
論理積代入演算子 (&&=) は、左オペランドが真値の場合にのみ右オペランドを評価し、左オペランドに代入します。
論理積代入演算子は短絡評価を行うため、x &&= y は x && (x = y) と同等です。ただし、式 x は一度だけ評価されます。
左辺が真値でない場合、論理積演算子の短絡が発生するため代入は実行されません。例えば、 x が const であっても、以下のコードはエラーが発生しません。
次のコードもセッターを起動しません。
実際、 x が真値である場合、 y はまったく評価されません。
| ECMAScript® 2027 Language Specification # sec-assignment-operators |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年9月11日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.