Baseline Widely available
Die Atomics.load()
statische Methode gibt einen Wert an einer gegebenen Position im Array zurück.
// 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
Syntax
Atomics.load(typedArray, index)
Parameter
typedArray
Ein Integer-getyptes Array. Eines von Int8Array
, Uint8Array
, Int16Array
, Uint16Array
, Int32Array
, Uint32Array
, BigInt64Array
, oder BigUint64Array
.
index
Die Position im typedArray
, von der geladen werden soll.
Der Wert an der gegebenen Position (typedArray[index]
).
TypeError
Wird ausgelöst, wenn typedArray
nicht einer der erlaubten Integer-Typen ist.
RangeError
Wird ausgelöst, wenn index
auÃerhalb der Grenzen von typedArray
liegt.
load
const sab = new SharedArrayBuffer(1024);
const ta = new Uint8Array(sab);
Atomics.add(ta, 0, 12);
Atomics.load(ta, 0); // 12
Spezifikationen Browser-Kompatibilität Siehe auch MDN-Feedback-Box War diese Ãbersetzung hilfreich?
Diese Seite wurde automatisch aus dem Englischen übersetzt.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4