<script>
//系统的构造函数 new Object();
//自定义的构造函数,模仿系统的构造函数
//函数名的首字母大写叫做构造函数
function Student(name,sex,age,height,weight){
this.name = name;
this,sex = sex;
this.age = age;
this.heigt = height;
thie.weight = weight;
this.sayHi = function () {
console.log("你哈,我的名字:"+ this.name);
}:
this.eat = function(eatName){
conlsole.log("我喜欢吃"+eatName);
};
}
var stu = new Student("哥哥",“女”,38);
stu.sayHi();
stu.eat("臭豆腐 榴莲,大蒜);
</script>
//系统的构造函数 new Object();
//自定义的构造函数,模仿系统的构造函数
//函数名的首字母大写叫做构造函数
function Student(name,sex,age,height,weight){
this.name = name;
this,sex = sex;
this.age = age;
this.heigt = height;
thie.weight = weight;
this.sayHi = function () {
console.log("你哈,我的名字:"+ this.name);
}:
this.eat = function(eatName){
conlsole.log("我喜欢吃"+eatName);
};
}
var stu = new Student("哥哥",“女”,38);
stu.sayHi();
stu.eat("臭豆腐 榴莲,大蒜);
</script>