class User {
age = 17
constructor(name){
this.name = name;
}
changeName(name){
this.name = name
}
changeAge(age){
this.age = age
}
}
function Food(name){
this.name = name;
console.log("你好");
// function add(){
// console.log('nihao');
// }
}
Food.prototype.add = function(){
console.log('nihao');
}
let user = new User("安徽")
let user1 = new User("香港")
let food = new Food("火鸡")
console.log(user);
console.log(user1);
console.log(food);
console.log(food.add());
console.log(user.changeName("user"))
console.log(user1.changeName("user1"));
console.log(user.changeAge("19"));
console.log(user1.changeAge("29"));
https://www.bilibili.com/video/BV1vJ411k7ZP?p=2&spm_id_from=pageDriver&vd_source=90a9c7618953f5d275200b2fa7aed461