ES6 Iterate over class methods
ecmascript-6, javascript
Solution
You can use Object.getOwnPropertyNames on the prototype:
Object.getOwnPropertyNames( Animal.prototype )
// [ 'constructor', 'getAnimalType' ]
Problem
Given this class; how would i iterate over the methods that it includes? ``` class Animal { constructor(type){ this.animalType = type; } getAnimalType(){ console.log('this.animalType: ', this.animalType ); } } let cat = window.cat = new Animal('cat') ``` What I have tried is the following with no success: ``` for (var each in Object.getPrototypeOf(cat) ){ console.log(each); } ```