TypedArray.prototype.toString()

TypedArray 实例的 toString() 方法返回一个表示指定类型数组及其元素的字符串。该方法与 Array.prototype.toString() 的算法相同。

¥The toString() method of TypedArray instances returns a string representing the specified typed array and its elements. This method has the same algorithm as Array.prototype.toString().

Try it

语法

¥Syntax

js
toString()

参数

¥Parameters

没有任何。

¥None.

返回值

¥Return value

表示类型化数组的元素的字符串。

¥A string representing the elements of the typed array.

描述

¥Description

详细信息请参见 Array.prototype.toString()。此方法不是通用的,只能在类型化数组实例上调用。

¥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

规范

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

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看