TypedArray.prototype.toString() - JavaScript | MDN

Try it

const uint8 = new Uint8Array([10, 20, 30, 40, 50]);

const uint8String = uint8.toString();

console.log(uint8String.startsWith("10"));
// Expected output: true

Syntax

Parameters

None.

Return value

A string representing the elements of the typed array.

Description

See Array.prototype.toString() for more details. This method is not generic and can only be called on typed array instances.

Examples

Converting a typed array to a string

js

const uint8 = new Uint8Array([1, 2, 3]);
// Explicit conversion
console.log(uint8.toString()); // 1,2,3
// Implicit conversion
console.log(`${uint8}`); // 1,2,3

Specifications

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

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.