why does for ... in only show methods defined with class.prototype?

Viewed 92

I have the following code, much reduced:

class Animal {
  speak() {}
}

Animal.prototype.speaklouder = function() {};

for (const key in new Animal()) {
  console.log("key", key);
}

This produces, in node 6.11.0,

key speaklouder

Why is that? I thought the class syntax is just sugar? I would expect the function speak to be also listed as an attribute.

1 Answers
Related