这篇翻译不完整。请帮忙从英语翻译这篇文章

一个TypedArray 对象描述一个底层的二进制数据缓存区的一个类似数组(array-like)视图。事实上,没有名为 TypedArray的全局对象,也没有一个名为的 TypedArray构造函数。相反,有许多不同的全局对象,下面会列出这些针对特定元素类型的类型化数组的构造函数。在下面的页面中,你会找到一些不管什么类型都公用的属性和方法。

语法

new TypedArray(); // ES2017中新增
new TypedArray(length); 
new TypedArray(typedArray); 
new TypedArray(object); 
new TypedArray(buffer [, byteOffset [, length]]); 

TypedArray()指的是以下的其中之一: 

Int8Array(); 
Uint8Array(); 
Uint8ClampedArray();
Int16Array(); 
Uint16Array();
Int32Array(); 
Uint32Array(); 
Float32Array(); 
Float64Array();

参数

length
当传入length参数时,一个内部数组缓冲区会被创建在内存中。该缓存区的大小是传入的length乘以数组中每个元素的字节数(BYTES_PER_ELEMENT),每个元素的值都为0。(译者注:每个元素的字节数是由具体的构造函数决定的,比如Int16Array的每个元素的字节数为2,Int32Array的每个元素的字节数为4)
typedArray
当传入一个包含任意类型元素的任意类型化数组对象typedArray(比如Int32Array)作为参数时,typeArray被复制到一个新的类型数组。typeArray中的每个值会在复制到新的数组之前根据构造器进行转化。新的生成的类型化数组对象将会有跟传入的数组相同的长度(译者注:比如原来的typeArray.length==2,那么新生成的数组的length也是2,只是数组中的每一项进行了转化)
object

当传入一个 object作为参数时,如同通过 TypedArray.from() 方法一样创建一个新的类型数组。

buffer, byteOffset, length
当传入一个buffer参数,或者再另外加上可选参数byteOffsetlength时,一个新的类型化数组视图将会被创建并可用于呈现传入的ArrayBuffer实例。byteOffsetlength指定类型化数组视图暴露的内存范围,如果两者都未传入,那么整个buffer都会被呈现。如果仅仅忽略length,那么buffer中偏移byteOffset后剩下的buffer将会被呈现。

描述

ECMAScript 6定义TypeArray构造器作为所有的类型化数组构造器(Int8Array,Int16Array等)的原型.该构造器不会直接暴露:没有全局的%TypedArray%和TypeArray属性.只能通过使用类似Object.getPrototypeOf(Int8Array.prototype)的方式进行访问.所有的类型化数组构造器(Int8Array,Int16Array等)都会继承TypeArray构造器的通用属性和方法.此外,所有的类型化数组原型(Int8Array.prototype,Int16Array.prototype等)的原型都以TypeArray.prototype作为原型.

TypedArray构造器自身不是特别有用.调用或在一个表达式中使用它都会抛出一个TypeError异常,除非在支持通过继承创建对象的JS引擎下运行.但直到现在还没有这样的JS引擎出现,因此TypeArray仅仅是对所有的类型化类构造器(Int8Array,Int16Array等)的方法和属性进行polyfill的时候比较有用.

当创建一个TypedArray实例(例如:Int8Array)时,一个数组缓冲区将被创建在内存中,如果ArrayBuffer对象被当作参数传给构造函数将使用传入的ArrayBuffer代替。缓冲区的地址被存储在实例的内部属性中,所有的%TypedArray%.prototype上的方法例如set value和get value等都会操作在数组缓冲区上。

属性访问

你可以参考使用标准数组索引数组中的元素的方法(其实就是方括号里面写下标).然而,原型链上面定义的索引属性(译者注:即用数字作为属性,例如Int16Array.prototype[0]=12;),在实例化的对象上面是获取不到该属性的(int16Array[0]==undefined).通过查询 ArrayBuffer 是找不到索引属性的.但您仍然可以使用命名属性(译者注:就是键不是数字的),就像所有对象一样。

// 设置和使用标准数组语法
var int16 = new Int16Array(2);
int16[0] = 42;
console.log(int16[0]); // 42

// Indexed properties on prototypes are not consulted (Fx 25)
Int8Array.prototype[20] = "foo";
(new Int8Array(32))[20]; // 0
// even when out of bound
Int8Array.prototype[20] = "foo";
(new Int8Array(8))[20]; // undefined
// or with negative integers
Int8Array.prototype[-1] = "foo";
(new Int8Array(8))[-1]; // undefined

// Named properties are allowed, though (Fx 30)
Int8Array.prototype.foo = "bar";
(new Int8Array(32)).foo; // "bar"

TypedArray 对象

类型 大小(字节单位) 描述 Web IDL type C语言中的等效类型
Int8Array 1 8位二进制带符号整数 -2^7~(2^7) - 1 byte int8_t
Uint8Array 1 8位无符号整数 0~(2^8) - 1 octet uint8_t
Int16Array 2 16位二进制带符号整数 -2^15~(2^15)-1 short int16_t
Uint16Array 2 16位无符号整数 0~(2^16) - 1 unsigned short uint16_t
Int32Array 4 32位二进制带符号整数 -2^31~(2^31)-1 long int32_t
Uint32Array 4 32位无符号整数 0~(2^32) - 1 unsigned int uint32_t
Float32Array 4 32位IEEE浮点数 unrestricted float float
Float64Array 8 64位IEEE浮点数 unrestricted double double

属性

TypedArray.BYTES_PER_ELEMENT
返回不同类型的数组对象的元素大小的数字值。
TypedArray.length
Length property whose value is 3.(译者注:应该是数组的长度吧???)
TypedArray.name
返回构造器的名称,例如"Int8Array".
get TypedArray[@@species]
用于创建派生对象的构造函数函数.
TypedArray.prototype
TypedArray的原型.

方法

TypedArray.from()
使用类数组(array-like)或迭代对象创建一个新的类型化数组.参见 Array.from().
TypedArray.of()
通过可变数量的参数创建新的类型化数组.参见 Array.of().

TypedArray 原型

所有的类型化数组都是继承自TypedArray.prototype.

属性

TypedArray.prototype.constructor
返回创建实例原型的构造函数.这是相应的typed array type的默认的构造函数.
TypedArray.prototype.buffer 只读
返回被格式化数组引用的ArrayBuffer. 创建时已被固化,因此是只读的.
TypedArray.prototype.byteLength 只读
返回从ArrayBuffer读取的字节长度. 创建时已被固化,因此是只读的.
TypedArray.prototype.byteOffset 只读
返回从ArrayBuffer读取时的字节偏移量.创建时已被固化,因此是只读的.
TypedArray.prototype.length 只读
返回在类型化数组中的元素的数量.创建时已被固化,因此是只读的.

方法

TypedArray.prototype.copyWithin()
浅拷贝数组的部分元素到同一数组的不同位置,且不改变数组的大小,返回该数组. 参见 Array.prototype.copyWithin().
TypedArray.prototype.entries()
返回一个 Array Iterator 对象,该对象包含数组中每一个索引的键值对.参见 Array.prototype.entries().
TypedArray.prototype.every()
测试数组的所有元素是否都通过了指定函数的测试. 参见Array.prototype.every().
TypedArray.prototype.fill()
将一个数组中指定区间的所有元素的值, 都替换成或者说填充成为某个固定的值. 参见 Array.prototype.fill().
TypedArray.prototype.filter()
使用指定的函数测试所有元素,并创建一个包含所有通过测试的元素的新数组. 参见 Array.prototype.filter().
TypedArray.prototype.find()
返回一个满足提供的函数的测试的元素,若是没有满足的元素则返回undefined . 参见 Array.prototype.find().
TypedArray.prototype.findIndex()
查找数组中某指定元素的索引, 如果找不到指定的元素, 则返回 -1. 参见 Array.prototype.findIndex().
TypedArray.prototype.forEach()
对数组的每个元素执行一次提供的函数(回调函数). 参见 Array.prototype.forEach().
TypedArray.prototype.includes()
确定一个类型化数组是否包括了某个元素,包含就返回true,不包含就返回false.参见 Array.prototype.includes().
TypedArray.prototype.indexOf()
返回数组中第一个等于指定值得元素的索引,如果找不到则返回-1. 参见 Array.prototype.indexOf().
TypedArray.prototype.join()
将数组中的所有元素连接成一个字符串. 参见 Array.prototype.join().
TypedArray.prototype.keys()
返回一个新的包含数组索引的数组迭代器. 参见 Array.prototype.keys().
TypedArray.prototype.lastIndexOf()
返回数组中最后一个等于指定值得元素的索引,如果找不到则返回-1.参见 Array.prototype.lastIndexOf().
TypedArray.prototype.map()
创建一个由原数组中的每个元素调用一个指定方法后的返回值组成的新数组.参见 Array.prototype.map().
TypedArray.prototype.move() 未实现
以前的不标准版本的 TypedArray.prototype.copyWithin().
TypedArray.prototype.reduce()
接收一个函数作为累加器(accumulator),数组中的每个值(从左到右)开始合并,最终为一个值. 参见Array.prototype.reduce().
TypedArray.prototype.reduceRight()
接受一个函数作为累加器(accumulator),让每个值(从右到左,亦即从尾到头)缩减为一个值.(与 reduce() 的执行方向相反). 参见Array.prototype.reduceRight().
TypedArray.prototype.reverse()
颠倒数组中元素的位置。第一个元素会成为最后一个,最后一个会成为第一个. 参见 Array.prototype.reverse().
TypedArray.prototype.set()
读取一个指定数组中的元素保存到格式化数组中.
TypedArray.prototype.slice()
浅复制(shallow copy)数组的一部分到一个新的数组,并返回这个新数组. 参见 Array.prototype.slice().
TypedArray.prototype.some()
数组中只要有一个元素满足提供的测试函数的测试就返回true,否则返回false. 参见 Array.prototype.some().
TypedArray.prototype.sort()
对数组进行排序,并返回原数组(是改变原数组). 参见 Array.prototype.sort().
TypedArray.prototype.subarray()
返回给定的起始和结束索引之间的元素组成的新的类型化数组.
TypedArray.prototype.values()
返回有数组中的元素组成的新的数组迭代对象. 参见 Array.prototype.values().
TypedArray.prototype.toLocaleString()
返回一个将数组中的每个元素本地化后组成的字符串. 参见 Array.prototype.toLocaleString().
TypedArray.prototype.toString()
返回一个由数组中的每个元素字符串化后组成的字符串. 参见 Array.prototype.toString().
TypedArray.prototype[@@iterator]()
返回一个包含数组中每个元素的新的数组迭代对象.

规范

规范 状态 说明
Typed Array Specification Obsolete Defined as TypedArray and ArrayBufferView interface with typed array view types. Superseded by ECMAScript 6.
ECMAScript 2015 (6th Edition, ECMA-262)
TypedArray Objects
Standard Initial definition in an ECMA standard. Specified behaviour for indexed and named properties. Specified that new is required.
ECMAScript Latest Draft (ECMA-262)
TypedArray Objects
Draft  

浏览器支持

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung InternetNode.js
Basic supportChrome Full support 7Edge Full support YesFirefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs Full support Yes
Constructor without argumentsChrome ? Edge ? Firefox Full support 55IE Full support 10Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 55Opera Android ? Safari iOS ? Samsung Internet Android ? nodejs ?
Indexed properties not consulting prototypeChrome Full support Yes
Notes
Full support Yes
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Edge ? Firefox Full support 25IE Full support 10
Notes
Full support 10
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Opera ? Safari ? WebView Android Full support Yes
Notes
Full support Yes
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Chrome Android Full support Yes
Notes
Full support Yes
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Edge Mobile ? Firefox Android Full support 25Opera Android ? Safari iOS ? Samsung Internet Android Full support Yesnodejs ?
Notes
?
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Iterable in constructorChrome ? Edge ? Firefox Full support 52IE Full support 10Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 52Opera Android ? Safari iOS ? Samsung Internet Android ? nodejs Full support 4.0.0
Named propertiesChrome Full support YesEdge ? Firefox Full support 30IE Full support 10Opera ? Safari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 30Opera Android ? Safari iOS ? Samsung Internet Android Full support Yesnodejs ?
TypedArray() without new throwsChrome ? Edge ? Firefox Full support 44IE No support NoOpera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 44Opera Android ? Safari iOS ? Samsung Internet Android ? nodejs Full support 0.12
BYTES_PER_ELEMENTChrome Full support 7Edge Full support YesFirefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs Full support Yes
bufferChrome Full support 7Edge Full support 14Firefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs Full support Yes
byteLengthChrome Full support 7Edge Full support 14Firefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs Full support Yes
byteOffsetChrome Full support 7Edge Full support 14Firefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs Full support Yes
copyWithinChrome Full support 45Edge Full support 14Firefox Full support 34IE No support NoOpera Full support 36Safari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile ? Firefox Android Full support 34Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs Full support 4.0.0
entriesChrome Full support 45Edge Full support 14Firefox Full support 37IE No support NoOpera Full support 36Safari No support NoWebView Android No support NoChrome Android Full support YesEdge Mobile ? Firefox Android Full support 37Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yesnodejs Full support 0.12
everyChrome Full support 45Edge Full support 14Firefox Full support 37IE No support NoOpera Full support 36Safari No support NoWebView Android No support NoChrome Android Full support YesEdge Mobile ? Firefox Android Full support 37Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yesnodejs Full support 4.0.0
fillChrome Full support 45Edge Full support 14Firefox Full support 37IE No support NoOpera Full support 36Safari No support NoWebView Android No support NoChrome Android Full support YesEdge Mobile ? Firefox Android Full support 37Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yesnodejs Full support 4.0.0
filterChrome Full support 45Edge Full support 14Firefox Full support 38IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android Full support YesEdge Mobile ? Firefox Android Full support 38Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yesnodejs Full support 4.0.0
findChrome Full support YesEdge Full support 14Firefox Full support 37IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile ? Firefox Android Full support 37Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs Full support 4.0.0
findIndexChrome Full support YesEdge Full support 14Firefox Full support 37IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile ? Firefox Android Full support 37Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs Full support 4.0.0
forEachChrome Full support YesEdge Full support 14Firefox Full support 38IE No support NoOpera ? Safari Full support 10WebView Android No support NoChrome Android Full support YesEdge Mobile ? Firefox Android Full support 38Opera Android ? Safari iOS ? Samsung Internet Android Full support Yesnodejs Full support 4.0.0
fromChrome Full support 45Edge Full support 14Firefox Full support 38IE No support NoOpera No support NoSafari Full support 10WebView Android No support NoChrome Android No support NoEdge Mobile ? Firefox Android Full support 38Opera Android No support NoSafari iOS Full support 10Samsung Internet Android No support Nonodejs Full support 4.0.0
includesChrome Full support 47Edge Full support 14Firefox Full support 43IE No support NoOpera Full support 34Safari Full support 10WebView Android No support NoChrome Android Full support 47Edge Mobile ? Firefox Android Full support 43Opera Android Full support 34Safari iOS Full support 10Samsung Internet Android Full support 5.0nodejs Full support 6.0.0
Full support 6.0.0
Full support 5.0.0
Disabled
Disabled From version 5.0.0: this feature is behind the --harmony runtime flag.
indexOfChrome Full support 45Edge Full support 14Firefox Full support 37
Notes
Full support 37
Notes
Notes Starting with Firefox 47, this method will no longer return -0. For example, new Uint8Array([0]).indexOf(0, -0) will now always return +0.
IE No support NoOpera Full support 32Safari No support NoWebView Android No support NoChrome Android Full support 45Edge Mobile Full support YesFirefox Android Full support 37
Notes
Full support 37
Notes
Notes Starting with Firefox 47, this method will no longer return -0. For example, new Uint8Array([0]).indexOf(0, -0) will now always return +0.
Opera Android Full support 32Safari iOS No support NoSamsung Internet Android Full support 5.0nodejs Full support 4.0.0
joinChrome Full support YesEdge Full support 14Firefox Full support 37IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 37Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yesnodejs Full support 4.0.0
keysChrome Full support YesEdge Full support 14Firefox Full support 37IE No support NoOpera No support NoSafari Full support 10WebView Android No support NoChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 37Opera Android No support NoSafari iOS Full support 10Samsung Internet Android Full support Yesnodejs Full support 0.12
lastIndexOfChrome Full support YesEdge Full support 14Firefox Full support 37
Notes
Full support 37
Notes
Notes Starting with Firefox 47, this method will no longer return -0. For example, new Uint8Array([0]).lastIndexOf(0, -0) will now always return +0.
IE No support NoOpera Full support YesSafari Full support 10WebView Android No support NoChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 37
Notes
Full support 37
Notes
Notes Starting with Firefox 47, this method will no longer return -0. For example, new Uint8Array([0]).lastIndexOf(0, -0) will now always return +0.
Opera Android Full support YesSafari iOS Full support 10Samsung Internet Android Full support Yesnodejs Full support 4.0.0
lengthChrome Full support 7Edge Full support 14Firefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs Full support Yes
mapChrome Full support YesEdge Full support 14Firefox Full support 38IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 38Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yesnodejs Full support 4.0.0
move
ExperimentalDeprecatedNon-standard
Chrome No support NoEdge No support NoFirefox No support 16 — 34
Notes
No support 16 — 34
Notes
Notes Was available in Aurora and Nightly channels only.
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support 38 — 34
Notes
No support 38 — 34
Notes
Notes Was available in Aurora and Nightly channels only.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
nameChrome Full support 7Edge Full support YesFirefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs Full support Yes
ofChrome Full support 45Edge Full support 14Firefox Full support 38IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile ? Firefox Android Full support 38Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs Full support 4.0.0
prototypeChrome Full support 7Edge Full support YesFirefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs Full support Yes
reduceChrome Full support 45Edge Full support 14Firefox Full support 37IE No support NoOpera Full support 32Safari Full support 10WebView Android ? Chrome Android ? Edge Mobile Full support YesFirefox Android Full support 37Opera Android No support NoSafari iOS Full support 10Samsung Internet Android ? nodejs Full support 4.0.0
reduceRightChrome Full support 45Edge Full support 14Firefox Full support 37IE No support NoOpera Full support 32Safari Full support 10WebView Android ? Chrome Android ? Edge Mobile Full support YesFirefox Android Full support 37Opera Android No support NoSafari iOS Full support 10Samsung Internet Android ? nodejs Full support 4.0.0
reverseChrome Full support 45Edge Full support 14Firefox Full support 37IE No support NoOpera Full support 32Safari Full support 10WebView Android ? Chrome Android ? Edge Mobile Full support YesFirefox Android Full support 37Opera Android No support NoSafari iOS Full support 10Samsung Internet Android ? nodejs Full support 4.0.0
setChrome Full support 7Edge Full support 14Firefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs ?
sliceChrome Full support 45Edge Full support 14Firefox Full support 38IE No support NoOpera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 38Opera Android ? Safari iOS ? Samsung Internet Android ? nodejs Full support 4.0.0
someChrome Full support 45Edge Full support 14Firefox Full support 37IE No support NoOpera Full support 32Safari Full support 10WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 37Opera Android No support NoSafari iOS Full support 10Samsung Internet Android ? nodejs Full support 4.0.0
sortChrome Full support YesEdge Full support 14Firefox Full support 46IE No support NoOpera Full support YesSafari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 46Opera Android ? Safari iOS ? Samsung Internet Android ? nodejs Full support 4.0.0
subarrayChrome Full support 7Edge Full support 14Firefox Full support 4IE Full support 10Opera Full support 11.6Safari Full support 5.1WebView Android Full support 4Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.6Safari iOS Full support 4.2Samsung Internet Android Full support Yesnodejs Full support 0.12
toLocaleStringChrome Full support YesEdge ? Firefox Full support 51IE Full support 10Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 51Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs ?
toStringChrome Full support YesEdge ? Firefox Full support 51IE No support NoOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 51Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs ?
valuesChrome Full support YesEdge Full support 14Firefox Full support 37IE No support NoOpera Full support 26Safari Full support 10WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 37Opera Android Full support YesSafari iOS Full support 10Samsung Internet Android Full support Yesnodejs Full support 0.12
@@iteratorChrome Full support YesEdge ? Firefox Full support 36
Full support 36
No support 27 — 36
Notes Alternate Name
Notes A placeholder property named @@iterator is used.
Alternate Name Uses the non-standard name: @@iterator
No support 17 — 27
Notes Alternate Name
Notes A placeholder property named iterator is used.
Alternate Name Uses the non-standard name: iterator
IE No support NoOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 36
Full support 36
No support 27 — 36
Notes Alternate Name
Notes A placeholder property named @@iterator is used.
Alternate Name Uses the non-standard name: @@iterator
No support 17 — 27
Notes Alternate Name
Notes A placeholder property named iterator is used.
Alternate Name Uses the non-standard name: iterator
Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support 0.12
@@speciesChrome Full support YesEdge ? Firefox Full support 48IE No support NoOpera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 48Opera Android ? Safari iOS ? Samsung Internet Android ? nodejs Full support 6.5.0
Full support 6.5.0
Full support 6.0.0
Disabled
Disabled From version 6.0.0: this feature is behind the --harmony runtime flag.

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.
Uses a non-standard name.
Uses a non-standard name.

兼容性注意事项

从ECMAScript 2015 (ES6)开始,TypedArray 构造函数使用的时候必须要使用new.从现在开始不使用new调用TypedArray构造函数将会抛出异常TypeError

var dv = Int8Array([1, 2, 3]);
// TypeError: 不使用new调用内置的Int8Array构造函数是被禁止的
var dv = new Int8Array([1, 2, 3]);

相关链接

文档标签和贡献者

最后编辑者: tangtangtangtangtang,