Javascript 为什么懒惰的getter使用原型而不使用类?

Javascript 为什么懒惰的getter使用原型而不使用类?,javascript,class,ecmascript-6,setter,getter,Javascript,Class,Ecmascript 6,Setter,Getter,考虑以下代码: const defclass=prototype=>{ const constructor=prototype.constructor; constructor.prototype=原型; 返回构造函数; }; const Person=defclass({ 构造函数:函数人(名字、姓氏){ this.firstname=firstname; this.lastname=lastname; }, 获取全名(){ 删除this.fullname;//不在实例上删除 返回this.

考虑以下代码:

const defclass=prototype=>{
const constructor=prototype.constructor;
constructor.prototype=原型;
返回构造函数;
};
const Person=defclass({
构造函数:函数人(名字、姓氏){
this.firstname=firstname;
this.lastname=lastname;
},
获取全名(){
删除this.fullname;//不在实例上删除
返回this.fullname=this.firstname+“”+this.lastname;
}
});
const john=新人(“john”、“Doe”);
const-jane=新的人(“jane”、“Doe”);
console.log(john.fullname);//无名氏
console.log(jane.fullname);//Jane Doe
我确实收到了与第一个代码相同的错误:

const defclass=prototype=>{
const constructor=prototype.constructor;
constructor.prototype=原型;
返回构造函数;
};
const Person=defclass({
构造函数:函数人(名字、姓氏){
this.firstname=firstname;
this.lastname=lastname;
},
获取全名(){
“严格使用”;
//      ^^^^^^^^^^^^
返回this.fullname=this.firstname+“”+this.lastname;
}
});
const john=新人(“john”、“Doe”);
const-jane=新的人(“jane”、“Doe”);
console.log(john.fullname);//无名氏

console.log(jane.fullname);//简·多伊是有道理的。然而,我相信这在严格模式下不应该是一个错误。@AaditMShah你为什么这么认为?没关系。你的编辑澄清了一些事情。我明白为什么现在在严格模式下是不允许的。