| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load | [Back] [Original] |
Get to know MDN better
// Create a SharedArrayBuffer with a size in bytes
const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);
uint8[0] = 5;
// 5 + 2 = 7
console.log(Atomics.add(uint8, 0, 2));
// Expected output: 5
console.log(Atomics.load(uint8, 0));
// Expected output: 7
Atomics.load(typedArray, index)
typedArrayInt8ArrayUint8ArrayInt16ArrayUint16ArrayInt32ArrayUint32ArrayBigInt64Array BigUint64Array
indextypedArray
typedArray[index]
TypeError typedArray
RangeError index typedArray
const sab = new SharedArrayBuffer(1024);
const ta = new Uint8Array(sab);
Atomics.add(ta, 0, 12);
Atomics.load(ta, 0); // 12
| ECMAScript 2027 LanguageSpecification # sec-atomics.load |
| Web Proxy Viewer | New URL | Original Page |