Reflect.construct()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.
Reflect.construct()
方法的行为有点像 new
操作符 构造函数,相当于运行 new target(...args)
.
语法
Reflect.construct(target, argumentsList[, newTarget])
参数
target
-
被运行的目标构造函数
argumentsList
-
类数组,目标构造函数调用时的参数。
newTarget
可选-
作为新创建对象的原型对象的
constructor
属性,参考new.target
操作符,默认值为target
。
返回值
以target
(如果newTarget
存在,则为newTarget
)函数为构造函数,argumentList
为其初始化参数的对象实例。