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/slice below:

TypedArray.prototype.slice() - JavaScript | MDN

TypedArray.prototype.slice()

Baseline Widely available

slice() は TypedArray インスタンスのメソッドで、型付き配列の一部を start から end (end は含まれない)まで選択された新しい型付き配列オブジェクトにコピーして返します。元の型付き配列は変更されません。このメソッドは Array.prototype.slice() と同じアルゴリズムです。

試してみましょう
const uint8 = new Uint8Array([10, 20, 30, 40, 50]);
const array1 = uint8.slice(1, 3);

console.log(array1);
// Expected output: Uint8Array [20, 30]
構文
slice()
slice(start)
slice(start, end)
引数
start 省略可

抽出を始める位置を示すゼロ基点のインデックスで、整数に変換されます。

end 省略可

抽出を終了する位置を示すゼロ基点のインデックスで、整数に変換されます。 slice() はここまでを抽出しますが、 end は含みません。

返値

抽出された要素が入った新しい型付き配列です。

解説

詳細については、 Array.prototype.slice() をご覧ください。このメソッドは汎用的ではなく、型付き配列インスタンスに対してのみ呼び出すことができます。

例 例: 既存の配列の一部を返す
const uint8 = new Uint8Array([1, 2, 3]);
uint8.slice(1); // Uint8Array [ 2, 3 ]
uint8.slice(2); // Uint8Array [ 3 ]
uint8.slice(-2); // Uint8Array [ 2, 3 ]
uint8.slice(0, 1); // Uint8Array [ 1 ]
仕様書 ブラウザーの互換性 関連情報

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