[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load [Back]  [Original]

Atomics.load() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Atomics.load()

202112

Atomics.load()

// 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

js
Atomics.load(typedArray, index)

typedArray

Int8ArrayUint8ArrayInt16ArrayUint16ArrayInt32ArrayUint32ArrayBigInt64Array BigUint64Array

index

typedArray

typedArray[index]

TypeError

typedArray

RangeError

index typedArray

load()

js
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