extends

class Chef {


    constructor(food) {
        this.food = food;
        this.data;
    }

    cook() {
        console.log('我在做饭' + this.food);
    }

    set menu(data) {   //set方法
        this.data = data;
    }

    get menu() {     //get方法
        return this.data;
    }

    static show() {
        console.log("show")
    }


}


class ChefMySelf extends Chef {

    constructor(food) {
        super(food)
    }

}

let chefMySelf = new ChefMySelf('米饭');
chefMySelf.cook()








你可能感兴趣的:(extends)