相关疑难解决方法(0)

ES6迭代类方法

鉴于此课程; 我将如何迭代它包含的方法?

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)

javascript ecmascript-6

34
推荐指数
5
解决办法
1万
查看次数

标签 统计

ecmascript-6 ×1

javascript ×1