TypedArray

一个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)作为参数时, typedArray被复制到一个新的类型数组。 typedArray中的每个值会在复制到新的数组之前根据构造器进行转化。新的生成的类型化数组对象将会有跟传入的数组相同的长度(译者注:比如原来的typedArray.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
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
TypedArray Chrome Full support 7 Edge Full support 12 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs Full support Yes
BYTES_PER_ELEMENT Chrome Full support 7 Edge Full support 12 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs Full support Yes
buffer Chrome Full support 7 Edge Full support 14 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs Full support Yes
byteLength Chrome Full support 7 Edge Full support 14 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs Full support Yes
byteOffset Chrome Full support 7 Edge Full support 14 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs Full support Yes
Constructor without arguments Chrome Full support 7 Edge Full support 12 Firefox Full support 55 IE Full support 10 Opera Full support Yes Safari Full support 5.1 WebView Android Full support ≤37 Chrome Android Full support 18 Firefox Android Full support 55 Opera Android Full support Yes Safari iOS Full support 5 Samsung Internet Android Full support 1.0 nodejs ?
copyWithin Chrome Full support 45 Edge Full support 14 Firefox Full support 34 IE No support No Opera Full support 36 Safari No support No WebView Android No support No Chrome Android No support No Firefox Android Full support 34 Opera Android No support No Safari iOS No support No Samsung Internet Android No support No nodejs Full support 4.0.0
entries Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 36 Safari No support No WebView Android No support No Chrome Android Full support 45 Firefox Android Full support 37 Opera Android No support No Safari iOS No support No Samsung Internet Android Full support Yes nodejs Full support 0.12
every Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 36 Safari No support No WebView Android No support No Chrome Android Full support 45 Firefox Android Full support 37 Opera Android No support No Safari iOS No support No Samsung Internet Android Full support Yes nodejs Full support 4.0.0
fill Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 36 Safari No support No WebView Android No support No Chrome Android Full support 45 Firefox Android Full support 37 Opera Android No support No Safari iOS No support No Samsung Internet Android Full support Yes nodejs Full support 4.0.0
filter Chrome Full support 45 Edge Full support 14 Firefox Full support 38 IE No support No Opera No support No Safari No support No WebView Android No support No Chrome Android Full support 45 Firefox Android Full support 38 Opera Android No support No Safari iOS No support No Samsung Internet Android Full support Yes nodejs Full support 4.0.0
find Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 32 Safari No support No WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 37 Opera Android Full support 32 Safari iOS No support No Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
findIndex Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 32 Safari No support No WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 37 Opera Android Full support 32 Safari iOS No support No Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
forEach Chrome Full support 45 Edge Full support 14 Firefox Full support 38 IE No support No Opera Full support 32 Safari Full support 10 WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 38 Opera Android Full support 32 Safari iOS ? Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
from Chrome Full support 45 Edge Full support 14 Firefox Full support 38 IE No support No Opera No support No Safari Full support 10 WebView Android No support No Chrome Android No support No Firefox Android Full support 38 Opera Android No support No Safari iOS Full support 10 Samsung Internet Android No support No nodejs Full support 4.0.0
includes Chrome Full support 47 Edge Full support 14 Firefox Full support 43 IE No support No Opera Full support 34 Safari Full support 10 WebView Android No support No Chrome Android Full support 47 Firefox Android Full support 43 Opera Android Full support 34 Safari iOS Full support 10 Samsung Internet Android Full support 5.0 nodejs 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.
Indexed properties not consulting prototype Chrome Full support 7
Notes
Full support 7
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Edge Full support 12
Notes
Full support 12
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Firefox Full support 25 IE 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 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.
Safari Full support 5.1
Notes
Full support 5.1
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
WebView Android Full support ≤37
Notes
Full support ≤37
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Chrome Android Full support 18
Notes
Full support 18
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Firefox Android Full support 25 Opera 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.
Safari iOS Full support 5
Notes
Full support 5
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Samsung Internet Android Full support 1.0
Notes
Full support 1.0
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
nodejs ?
Notes
?
Notes
Notes Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
indexOf Chrome Full support 45 Edge Full support 14 Firefox 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 No Opera Full support 32 Safari No support No WebView Android No support No Chrome Android Full support 45 Firefox 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 32 Safari iOS No support No Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
Iterable in constructor Chrome Full support 39 Edge Full support 14 Firefox Full support 52 IE No support No Opera Full support 26 Safari ? WebView Android Full support 39 Chrome Android Full support 39 Firefox Android Full support 52 Opera Android Full support 26 Safari iOS ? Samsung Internet Android Full support 4.0 nodejs Full support 4.0.0
join Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 32 Safari No support No WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 37 Opera Android Full support 32 Safari iOS No support No Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
keys Chrome Full support 38 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 25 Safari Full support 10 WebView Android Full support 38 Chrome Android Full support 38 Firefox Android Full support 37 Opera Android Full support 25 Safari iOS Full support 10 Samsung Internet Android Full support 3.0 nodejs Full support 0.12
lastIndexOf Chrome Full support 45 Edge Full support 14 Firefox 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 No Opera Full support 32 Safari Full support 10 WebView Android Full support 45 Chrome Android Full support 45 Firefox 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 32 Safari iOS Full support 10 Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
length Chrome Full support 7 Edge Full support 14 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs Full support Yes
map Chrome Full support 45 Edge Full support 14 Firefox Full support 38 IE No support No Opera Full support 32 Safari No support No WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 38 Opera Android Full support 32 Safari iOS No support No Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
move
Experimental Deprecated Non-standard
Chrome No support No Edge No support No Firefox No support 16 — 34
Notes
No support 16 — 34
Notes
Notes Was available in Aurora and Nightly channels only.
IE No support No Opera No support No Safari No support No WebView Android No support No Chrome Android No support No Firefox Android No support 16 — 34
Notes
No support 16 — 34
Notes
Notes Was available in Aurora and Nightly channels only.
Opera Android No support No Safari iOS No support No Samsung Internet Android No support No nodejs No support No
name Chrome Full support 7 Edge Full support 12 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs Full support Yes
Named properties Chrome Full support 7 Edge Full support 12 Firefox Full support 30 IE Full support 10 Opera Full support Yes Safari Full support 5.1 WebView Android Full support ≤37 Chrome Android Full support 18 Firefox Android Full support 30 Opera Android Full support Yes Safari iOS Full support 5 Samsung Internet Android Full support 1.0 nodejs ?
TypedArray() without new throws Chrome Full support 7 Edge Full support 14 Firefox Full support 44 IE No support No Opera Full support Yes Safari Full support 5.1 WebView Android Full support ≤37 Chrome Android Full support 18 Firefox Android Full support 44 Opera Android Full support Yes Safari iOS Full support 5 Samsung Internet Android Full support 1.0 nodejs Full support 0.12
of Chrome Full support 45 Edge Full support 14 Firefox Full support 38 IE No support No Opera No support No Safari No support No WebView Android No support No Chrome Android No support No Firefox Android Full support 38 Opera Android No support No Safari iOS No support No Samsung Internet Android No support No nodejs Full support 4.0.0
prototype Chrome Full support 7 Edge Full support 12 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs Full support Yes
reduce Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 32 Safari Full support 10 WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 37 Opera Android No support No Safari iOS Full support 10 Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
reduceRight Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 32 Safari Full support 10 WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 37 Opera Android No support No Safari iOS Full support 10 Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
reverse Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 32 Safari Full support 10 WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 37 Opera Android No support No Safari iOS Full support 10 Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
set Chrome Full support 7 Edge Full support 14 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs ?
slice Chrome Full support 45 Edge Full support 14 Firefox Full support 38 IE No support No Opera Full support 32 Safari ? WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 38 Opera Android ? Safari iOS ? Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
some Chrome Full support 45 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 32 Safari Full support 10 WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 37 Opera Android No support No Safari iOS Full support 10 Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
sort Chrome Full support 45 Edge Full support 14 Firefox Full support 46 IE No support No Opera Full support 32 Safari ? WebView Android Full support 45 Chrome Android Full support 45 Firefox Android Full support 46 Opera Android Full support 32 Safari iOS ? Samsung Internet Android Full support 5.0 nodejs Full support 4.0.0
subarray Chrome Full support 7 Edge Full support 14 Firefox Full support 4 IE Full support 10 Opera Full support 11.6 Safari Full support 5.1 WebView Android Full support 4 Chrome Android Full support 18 Firefox Android Full support 4 Opera Android Full support 12 Safari iOS Full support 4.2 Samsung Internet Android Full support Yes nodejs Full support 0.12
toLocaleString Chrome Full support 7 Edge Full support 12 Firefox Full support 51 IE Full support 10 Opera Full support Yes Safari Full support 5.1 WebView Android Full support ≤37 Chrome Android Full support 18 Firefox Android Full support 51 Opera Android Full support Yes Safari iOS Full support 5 Samsung Internet Android Full support 1.0 nodejs ?
toString Chrome Full support 7 Edge Full support 12 Firefox Full support 51 IE Full support 10 Opera Full support Yes Safari Full support 5.1 WebView Android Full support ≤37 Chrome Android Full support 18 Firefox Android Full support 51 Opera Android Full support Yes Safari iOS Full support 5 Samsung Internet Android Full support 1.0 nodejs ?
values Chrome Full support 38 Edge Full support 14 Firefox Full support 37 IE No support No Opera Full support 25 Safari Full support 10 WebView Android Full support 38 Chrome Android Full support 38 Firefox Android Full support 37 Opera Android Full support 25 Safari iOS Full support 10 Samsung Internet Android Full support 3.0 nodejs Full support 0.12
@@iterator Chrome Full support 38 Edge Full support 12 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 No Opera Full support 25 Safari Full support Yes WebView Android Full support 38 Chrome Android Full support 38 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 25 Safari iOS Full support Yes Samsung Internet Android Full support 3.0 nodejs Full support 0.12
@@species Chrome Full support 51 Edge Full support 13 Firefox Full support 48 IE No support No Opera Full support 38 Safari ? WebView Android Full support 51 Chrome Android Full support 51 Firefox Android Full support 48 Opera Android Full support 41 Safari iOS ? Samsung Internet Android Full support 5.0 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]);

相关链接