Baseline Widely available
La méthode statique Atomics.load()
renvoie une valeur située à une position donnée du tableau.
// 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
Syntaxe
Atomics.load(typedArray, index);
Paramètres
typedArray
Un tableau typé entier partagé parmi Int8Array
, Uint8Array
, Int16Array
, Uint16Array
, Int32Array
ou Uint32Array
.
index
La position du tableau typedArray
qu'on souhaite charger.
La valeur à la position indiquée (typedArray[index]
).
TypeError
si le type de typedArray
n'est pas un des types entiers autorisés.TypeError
si typedArray
n'est pas tableau typé partagé.RangeError
si index
est en dehors des limites de typedArray
.var sab = new SharedArrayBuffer(1024);
var ta = new Uint8Array(sab);
Atomics.add(ta, 0, 12);
Atomics.load(ta, 0); // 12
Spécifications Compatibilité des navigateurs Voir aussi
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