Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. JavaScript-Referenz
  4. Eingebaute Standardobjekte
  5. Atomics
  6. load()

Dieser Inhalt wurde automatisch aus dem Englischen übersetzt, und kann Fehler enthalten.Erfahre mehr über dieses Experiment.

View in EnglishAlways switch to English

Atomics.load()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨Dezember 2021⁩.

DieAtomics.load() statische Methode gibt einen Wert an einer gegebenen Position im Array zurück.

Probieren Sie es aus

// Create a SharedArrayBuffer with a size in bytesconst buffer = new SharedArrayBuffer(16);const uint8 = new Uint8Array(buffer);uint8[0] = 5;// 5 + 2 = 7console.log(Atomics.add(uint8, 0, 2));// Expected output: 5console.log(Atomics.load(uint8, 0));// Expected output: 7

Syntax

js
Atomics.load(typedArray, index)

Parameter

typedArray

Ein Integer-getyptes Array. Eines vonInt8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,BigInt64Array, oderBigUint64Array.

index

Die Position imtypedArray, von der geladen werden soll.

Rückgabewert

Der Wert an der gegebenen Position (typedArray[index]).

Ausnahmen

TypeError

Wird ausgelöst, wenntypedArray nicht einer der erlaubten Integer-Typen ist.

RangeError

Wird ausgelöst, wennindex außerhalb der Grenzen vontypedArray liegt.

Beispiele

Verwendung vonload

js
const sab = new SharedArrayBuffer(1024);const ta = new Uint8Array(sab);Atomics.add(ta, 0, 12);Atomics.load(ta, 0); // 12

Spezifikationen

Specification
ECMAScript® 2026 Language Specification
# sec-atomics.load

Browser-Kompatibilität

Siehe auch

Help improve MDN

Learn how to contribute Diese Seite wurde automatisch aus dem Englischen übersetzt.

[8]ページ先頭

©2009-2025 Movatter.jp