以下のコードはChrome V8ではfalseを記録しますが、Babelではtrueを記録します。 feedback from Googleは、falseを記録することは、どのように記録されるべきかということであり、trueを記録することはBabelのバグです。私はES6の仕様を見て、これの背後にあるメカニズムをまだ理解できませんでした。どんな考えにも感謝します!Chrome V8でObjectから拡張されたクラスをインスタンス化するときにsuper()が引数を渡さない
class NewObj extends Object{
constructor(){
super(...arguments); // In V8, after arguments === [{attr: true}]
// is passed as parameter to super(),
// this === NewObj{} in V8;
// but this === NewObj{attr: true} in Babel.
}
}
var o = new NewObj({attr: true});
console.log(o.attr === true);
私はそのバグに対する応答を理解していません。 'super()'コールには引数リストを含めることが最も確実であり、Objectコンストラクタはその引数に注意を払うことになっています。 – Pointy
これはChromiumバグです。私はMicrosoft Edgeでテストしました。 'true'を返します。 – Lewis