在 VS Code 的源代码中,我发现了这样一段代码:
(打字稿)
/**
* Creates a new object of the provided class and will call the constructor with
* any additional argument supplied.
*/
export function create(ctor: Function, ...args: any[]): any {
let obj = Object.create(ctor.prototype);
ctor.apply(obj, args);
return obj;
}
我认为它与new ctor(...args)
.
不是吗?