function Student(name,age,sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
//简单的原型写法
Student.prototype = {
//手动修改构造器的指向
constructor:Student,
height:"188",
weight:"55kg";
study:function () {
console.log("学习好开心啊");
},
eat:function () {
console.log("我要吃好吃的");
}
};
//实例化对象
var Stu = new Student("小明",20,"男");
Stu.eat();
Stu.study();
console.dir(Student);
网友评论