1.定义一个类
class Person{
constructor(name,age){
this.name = name;
this.age = age;
}
//实例私有属性
friends = [];
sayName(){
console.log(this.name);
}
//类中的静态方法
static sayAae(){
console.log(this.age);
}
//类中的静态属性
static test = 'hello';
}
class Person{
constructor(name,age){
this.name = name;
this.age = age;
}
//实例私有属性
friends = [];
sayName(){
console.log(this.name);
}
//类中的静态方法
static sayAae(){
console.log(this.age);
}
//类中的静态属性
static test = 'hello';
}