| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2021 12.
Atomics.add() .
.
// Create a SharedArrayBuffer with a size in bytes
const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);
uint8[0] = 7;
// 7 + 2 = 9
console.log(Atomics.add(uint8, 0, 2));
// Expected output: 7
console.log(Atomics.load(uint8, 0));
// Expected output: 9
Atomics.add(typedArray, index, value)
typedArray . Int8Array, Uint8Array,
Int16Array, Uint16Array, Int32Array,
Uint32Array, BigInt64Array,
BigUint64Array .
indexvalue typedArray .
value.
(typedArray[index]).
typedArray TypeError .index typedArray RangeError .const sab = new SharedArrayBuffer(1024);
const ta = new Uint8Array(sab);
Atomics.add(ta, 0, 12); // 0 .
Atomics.load(ta, 0); // 12
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-atomics.add |
This page was last modified on 2025 2 11 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |