其他分享
首页 > 其他分享> > class声明类语法

class声明类语法

作者:互联网



class User{
    // 属性
    sitr='hdsj';
    constructor(name){
        this.name=name;
    }
    getName(){
        return this.name;
    }
    changeSite(value){
        this.site=value;
    }
    show(){
        return `${this.site}:${this.name}`;
    }
}
let hd=new User("hdr");
console.log(hd.getName());
console.log(User==User.prototype.constructor)

hd.changeSite('ahdf'); console.log(hd.show());
 
 

 

标签:console,name,show,语法,User,声明,class,hd,log
来源: https://www.cnblogs.com/yyy1234/p/15856562.html