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/TypedArray/of below:

TypedArray.of() - JavaScript | MDN

TypedArray.of()

Baseline Widely available

TypedArray.of() メソッドは、引数の変数番号から新しい型付き配列を生成します。このメソッドは Array.of() とほぼ同じです。

試してみましょう
const int16array = Int16Array.of("10", "20", "30", "40", "50");

console.log(int16array);
// Expected output: Int16Array [10, 20, 30, 40, 50]
構文
TypedArray.of()
TypedArray.of(element1)
TypedArray.of(element1, element2)
TypedArray.of(element1, element2, /* …, */ elementN)

ここで TypedArray は次のいずれかです。

引数
element1, …, elementN

型付き配列を作成するのに使われる要素です。

返値

新しい TypedArray のインスタンスです。

解説

詳細については、 Array.of() をご覧ください。 Array.of() と TypedArray.of() との間にはいくつか微妙な違いがあります。

例 of() の使用
Uint8Array.of(1); // Uint8Array [ 1 ]
Int8Array.of("1", "2", "3"); // Int8Array [ 1, 2, 3 ]
Float32Array.of(1, 2, 3); // Float32Array [ 1, 2, 3 ]
Int16Array.of(undefined); // Int16Array [ 0 ]
仕様書 ブラウザーの互換性 関連情報

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