Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
// *声明一个类
class Product{
// *构造器初始化
constructor(name,num,price){
// *自有成员
this.name=name;
this.num=num;
this.price=price;
}
// *共享成员(原型成员)
getInfo(){
return `名称:${this.name},数量:${this.num}台,单价:${this.price}元`;
}
// *静态成员
static status="正在热卖";
}
// *构造器new出实例并传参:
const product1=new Product('联想电脑',10,5600);
console.log(product1.getInfo());
console.log(Product.status);
// *1.数组解构
// *模板=值(数组)
let [name1,num,price]=['华为手机',8,5000];
console.log(name1,num,price);
// *更新
[name1,num,price]=['华硕电脑',6,5800];
console.log(name1,num,price);
// *2.对象解构
let{id,name2,num2,price2}={id:1,name2:'海尔空调',num2:5,price2:4500};
console.log(id,name2,num2,price2);
// *更新
({id,name2,num2,price2}={id:2,name2:'海信冰箱',num2:6,price2:3500});
console.log(id,name2,num2,price2);