首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

TypedArray.of

TypedArray.of()方法创建一个具有可变数量参数的新类型数组?。此方法几乎与Array.of()相同。

语法

代码语言:javascript
复制
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的这个值不是构造函数,TypedArray.of将抛出一个TypeError,其中Array.of默认创建一个新的 Array

示例

代码语言:javascript
复制
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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com