TypedArray.of()
TypedArray.of()
静态方法从可变数量的参数创建一个新的 类型数组。该方法与 Array.of()
几乎相同。
¥The TypedArray.of()
static method creates a new
typed array from a variable number of arguments. This method is nearly the same as
Array.of()
.
Try it
语法
¥Syntax
js
TypedArray.of()
TypedArray.of(element1)
TypedArray.of(element1, element2)
TypedArray.of(element1, element2, /* …, */ elementN)
其中 TypedArray
是以下之一:
¥Where TypedArray
is one of:
参数
返回值
描述
¥Description
详细信息请参见 Array.of()
。Array.of()
和 TypedArray.of()
之间有一些细微的区别:
¥See Array.of()
for more details. There are some subtle distinctions between Array.of()
and
TypedArray.of()
:
- 如果传递给
TypedArray.of()
的this
值不是构造函数,则TypedArray.from()
将抛出TypeError
,而Array.of()
默认创建新的Array
。 TypedArray.of()
使用[[Set]]
,而Array.of()
使用[[DefineOwnProperty]]
。因此,当使用Proxy
对象时,它会调用handler.set()
来创建新元素,而不是handler.defineProperty()
。
示例
使用()
规范
Specification |
---|
ECMAScript Language Specification # sec-%typedarray%.of |
浏览器兼容性
BCD tables only load in the browser