JavaScript: Confusion with Class Properties and Prototype Inheritance in ES6
I'm building a feature where I've been banging my head against this for hours. I'm working with an scenario with class properties in JavaScript ES6 and prototype inheritance. I've defined a base class `Animal` with a property `species` and a derived class `Dog` that adds a method `bark`. However, when I create an instance of `Dog` and attempt to access `species`, I get `undefined`. Here's a simplified version of my code: ```javascript class Animal { constructor() { this.species = 'Generic Animal'; } } class Dog extends Animal { constructor(name) { super(); this.name = name; } bark() { console.log(`${this.name} says: Woof!`); } } const myDog = new Dog('Buddy'); console.log(myDog.species); // outputs undefined myDog.bark(); // outputs 'Buddy says: Woof!' ``` I've tried moving the `species` property to the `Dog` class and explicitly setting it there, but that feels like a workaround rather than a proper solution. I also checked the prototype chain using `console.log(Object.getPrototypeOf(myDog));` which confirms that `myDog` is indeed an instance of `Dog` and `Animal`. Is there something I'm missing about how ES6 handles properties in inherited classes? Any insights would be greatly appreciated! For context: I'm using Javascript on Ubuntu. What's the best practice here? Could someone point me to the right documentation?