TypedArray.of
TypedArray.of()方法创建一个具有可变数量参数的新类型数组 。此方法几乎与Array.of()相同。
语法
TypedArray.of(element0[, element1[, ...[, elementN]]])
where TypedArray is one of:
Int8Array
Uint8Array
Uint8ClampedArray
Int16Array
Uint16Array
Int32Array
Uint32Array
Float32Array
Float64Array参数
elementN创建类型数组的元素。
返回值
一个新的TypedArray 实例。
描述
Array.of()和 TypedArray.of()之间的一些细微区别:
TypedArray.of使用 [[Put]] 其中Array.of使用 [[DefineProperty]]。因此,当使用Proxy对象时,它调用handler.set创建新的元素,而不是handler.defineProperty。
示例
Uint8Array.of(1); // Uint8Array [ 1 ]
Int8Array.of('1', '2', '3'); // Int8Array [ 1, 2, 3 ]
Float32Array.of(1, 2, 3); // Float32Array [ 1, 2, 3 ]
Int16Array.of(undefined); // IntArray [ 0 ]规范
Specification | Status | Comment |
|---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262)The definition of '%TypedArray%.of' in that specification. | Standard | Initial definition. |
ECMAScript 2017 Draft (ECMA-262)The definition of '%TypedArray%.of' in that specification. | Draft | |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
Basic support | 45.0 | 38 (38) | No support | No support | No support |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
Basic support | No support | No support | 38.0 (38) | No support | No support | No support |
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

