TypedArray.prototype.toString()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

toString()TypedArray インスタンスのメソッドで、指定された配列とその要素を表す文字列を返します。このメソッドは Array.prototype.toString() と同じアルゴリズムです。

試してみましょう

構文

js
toString()

引数

なし。

返値

型付き配列の要素を表す文字列です。

解説

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

型付き配列を文字列へ変換

js
const uint8 = new Uint8Array([1, 2, 3]);
// 明示的な変換
console.log(uint8.toString()); // 1,2,3
// 暗黙の変換
console.log(`${uint8}`); // 1,2,3

仕様書

Specification
ECMAScript Language Specification
# sec-%typedarray%.prototype.tostring

ブラウザーの互換性

BCD tables only load in the browser

関連情報