A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store below:

Atomics.store() - JavaScript | MDN

Atomics.store()

Baseline Widely available

Atomics.store() は静的メソッドで、指定された値を配列内の指定した位置に格納し、その値を返します。

試してみましょう
// バイト単位でサイズを指定して SharedArrayBuffer を作成
const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);
uint8[0] = 5;

console.log(Atomics.store(uint8, 0, 2));
// 予想される結果: 2

console.log(Atomics.load(uint8, 0));
// 予想される結果: 2
構文
Atomics.store(typedArray, index, value)
引数
typedArray

整数の型付き配列です。 Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, BigUint64Array の何れかです。

index

typedArray で value を格納する位置です。

value

格納する値です。

返値

格納された値です。

例外
TypeError

typedArray が許可された整数型のいずれでもない場合に発生します。

RangeError

index が typedArray の範囲を超えている場合に発生します。

例 store() の使用
const sab = new SharedArrayBuffer(1024);
const ta = new Uint8Array(sab);

Atomics.store(ta, 0, 12); // 12
仕様書 ブラウザーの互換性 関連情報

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