以下代碼在Chrome V8中記錄爲false,但在Babel中記錄爲true。 feedback from Google表示記錄錯誤是它應該如何記錄真實是巴貝爾的錯誤。我研究了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
這是一個鉻錯誤。我已經在Microsoft Edge上進行了測試。它返回'true'。 – Lewis