为什么 extended 类 对方法使用原型而不是字段?

Why do extended classes uses prototypes for methods but not for fields?

看看这个简单的代码:

class Animal {
    someField = 42;
    animalFunc() {
        console.log('animal')
    }
}
class Lion extends Animal {
    lionFunc() {
        console.loge('lion')
    }
}
let lion = new Lion();
console.log(lion)

Chrome 中的结果是:

正如我们所见,实例方法在原型上(对于每个构造函数)

问题:

为什么字段而不是方法不在原型上?
我的意思是,someFieldAnimal 中,而不是在 Lion 中。

这是在 ECMAScript - 15.7.14 Runtime Semantics: ClassDefinitionEvaluation 25.f:

中看到的预期行为
f. Else if element is a ClassFieldDefinition Record, then
  i. If IsStatic of e is false, append element to instanceFields.
  ii. Else, append element to staticElements.

并在 29. 中:

Set F.[[Fields]] to instanceFields.

所以在我们看到这不是一个错误之后,让我们看看为什么:

简单来说:

我们知道,如果我们在原型上有一个函数,并且我们更改了该函数值,那么每个人都会更改它。

如果我们将 属性 放在原型上,并且某些实例更改了 属性 值,它也会更改其他实例中的 属性 值,自然不应发生这种行为所以我们将属性放在实例本身上。

对于静态属性,这是预期的行为,因为我们只有它们的一个实例,这就是它们在原型上的原因

额外:

this comment by Ranando D Washington-King 来自 class 字段提案

我提到的引用是关于 add an x data 属性 to the prototype [...][=43= 的问题]:

Every instance has a copy of the object. The expectation may or may not be exactly that. Consider in Java, the ability to define nested classes. In that case, it is definitely the desire that every instance be able to see the exact same class definition. On the other hand, consider assigning an empty array. The likely intention is for each instance to have its own copy of that array for storing instance-specific values.