鉴于此课程; 我将如何迭代它包含的方法?
class Animal {
constructor(type){
this.animalType = type;
}
getAnimalType(){
console.log('this.animalType: ', this.animalType );
}
}
let cat = window.cat = new Animal('cat')
Run Code Online (Sandbox Code Playgroud)
我试过的是以下但没有成功:
for (var each in Object.getPrototypeOf(cat) ){
console.log(each);
}
Run Code Online (Sandbox Code Playgroud)