Discuss / JavaScript / class 你是我的救星啊

class 你是我的救星啊

Topic source

alienation

#1 Created at ... [Delete] [Delete and Lock User]

不需要中介对象,不需要function,不需要prototype

回来了,都回来了

class Cat extends Animal{
    constructor(name){
        super(name)}
    say(){
        return `Hello, ${this.name}!`}
}

alienation

#2 Created at ... [Delete] [Delete and Lock User]

从现在的格式上看

constructor应该就是python的__init__方法,而且已经隐藏了super()从原型继承初始化方法

然后类特有的方法和constructor平级

prototype现在返回的等于是包括init在内的对象所有方法


  • 1

Reply