[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or [Back]  [Original]

Atomics.or() - 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

Atomics.or()

Baseline Widely available

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

Atomics.or() OR . .

In this article

// Create a SharedArrayBuffer with a size in bytes
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));
// Expected output: 5

console.log(Atomics.load(uint8, 0));
// Expected output: 7

js
Atomics.or(typedArray, index, value)

typedArray

. Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, BigUint64Array .

index

OR typedArray .

value

OR .

(typedArray[index]) .

OR a b 1 1 . OR .

a b a | b
0 0 0
0 1 1
1 0 1
1 1 1

, 5 | 1 OR 0101 10 5.

5  0101
1  0001
   ----
5  0101

or

js
const sab = new SharedArrayBuffer(1024);
const ta = new Uint8Array(sab);
ta[0] = 2;

Atomics.or(ta, 0, 1); //   2 .
Atomics.load(ta, 0); // 3

Specification
ECMAScript 2027 LanguageSpecification
# sec-atomics.or


Web Proxy Viewer  |  New URL  |  Original Page