Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

TypedArray.prototype.toString()

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!

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

Syntax

typedarray.toString()

Return value

A string representing the elements of the typed array.

Description

The TypedArray objects override the toString method of Object. For TypedArray objects, the toString method joins the array and returns one string containing each typed array element separated by commas. For example, the following code creates a typed array and uses toString to convert the array to a string.

var numbers = new Uint8Array([2, 5, 8, 1, 4])
numbers.toString(); // "2,5,8,1,4"

JavaScript calls the toString method automatically when a typed array is to be represented as a text value or when an array is referred to in a string concatenation.

Compatibility

If a browser doesn't support the TypedArray.prototype.toString() method yet, JavaScript will call the toString method of Object:

var numbers = new Uint8Array([2, 5, 8, 1, 4])
numbers.toString(); // "[object Uint8Array]"

Specifications

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'TypedArray.prototype.toString' in that specification.
Standard Initial definition.
ECMAScript 2017 Draft (ECMA-262)
The definition of 'Array.prototype.toString' in that specification.
Draft  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 51 (51) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) 51.0 (51) (Yes) (Yes) (Yes)

See also

文档标签和贡献者

 此页面的贡献者: fscholz
 最后编辑者: fscholz,