Die statische Atomics
.load()
Methode gibt den Wert an einer gegebenen Position in einem Array zurück.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
Atomics.load(typedArray, index)
Parameter
typedArray
- Ein geteiltes getrypted Integer Array. Eines von
Int8Array
,Uint8Array
,Int16Array
,Uint16Array
,Int32Array
oderUint32Array
. index
- Die Position in
typedArray
, von der der Wert geladen wird.
Rückgabewert
Der Wert an der gegebenen Position (typedArray[index]
).
Exceptions
- Erzeugt einen
TypeError
, wenntypedArray
nicht von einem erlaubten Integer Typ ist. - Erzeugt eine
TypeError
, wenntypedArray
kein geteilter Arraytyp ist. - Erzeugt ein
RangeError
, wenn derindex
nicht in den Grenzen vontypedArray
ist.
Beispiele
var sab = new SharedArrayBuffer(1024);
var ta = new Uint8Array(sab);
Atomics.add(ta, 0, 12);
Atomics.load(ta, 0); // 12
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript (ECMA-262) Die Definition von 'Atomics.load' in dieser Spezifikation. |
Lebender Standard | Initiale Definition in ES2017. |
Browserkompatibilität
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.