| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or | [Back] [Original] |
Get to know MDN better
// SharedArrayBuffer
const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);
uint8[0] = 5;
// 5 (0101) OR 2 (0010) = 7 (0111)
console.log(Atomics.or(uint8, 0, 2));
// : 5
console.log(Atomics.load(uint8, 0));
// : 7
Atomics.or(typedArray, index, value)
typedArray Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, BigUint64Array
indextypedArray OR
valueOR
(typedArray[index])
TypeErrortypedArray
RangeErrorindex typedArray
OR a b 1 1 OR
a |
b |
a | b |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
OR 5 | 1 0101 10 5
5 0101 1 0001 ---- 5 0101
const sab = new SharedArrayBuffer(1024);
const ta = new Uint8Array(sab);
ta[0] = 2;
Atomics.or(ta, 0, 1); // returns 2, the old value
Atomics.load(ta, 0); // 3
| ECMAScript 2027 LanguageSpecification # sec-atomics.or |
| Web Proxy Viewer | New URL | Original Page |