ECMA6 機能を使用せずにオブジェクト間でスプラットするにはどうすればよいですか?
試み
function can(arg0, arg1) {
return arg0 + arg1;
}
function foo(bar, haz) {
this.bar = bar;
this.haz = haz;
}
myArgs = [1,2];
can
私はただできる:
can.apply(this, myArgs);
で試すときfoo
:
new foo.apply(this, myArgs);
このエラーが発生します (を呼び出しているためnew
):
TypeError: function apply() { [native code] } is not a constructor