Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

ビット論理和代入 (|=)

BaselineWidely available

ビット論理和代入演算子 (|=) は、両方のオペランドの二進表現を使用し、それらに対してビット単位の OR 演算を実行して、結果を変数に代入します。

試してみましょう

let a = 5; // 00000000000000000000000000000101a |= 3; // 00000000000000000000000000000011console.log(a); // 00000000000000000000000000000111// Expected output: 7

構文

js
x |= y; // x = x | y

ビット論理和代入の使用

js
let a = 5;a |= 2; // 7// 5: 00000000000000000000000000000101// 2: 00000000000000000000000000000010// -----------------------------------// 7: 00000000000000000000000000000111

仕様書

Specification
ECMAScript® 2026 Language Specification
# sec-assignment-operators

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp