TypedArray.prototype.toString()
BaselineWidely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2017.
toString()
はTypedArray
インスタンスのメソッドで、指定された配列とその要素を表す文字列を返します。このメソッドはArray.prototype.toString()
と同じアルゴリズムです。
試してみましょう
const uint8 = new Uint8Array([10, 20, 30, 40, 50]);const uint8String = uint8.toString();console.log(uint8String.startsWith("10"));// Expected output: true
構文
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® 2026 Language Specification # sec-%typedarray%.prototype.tostring |