创建对象最常用的的方法
function Student(id,name){
this.id = id;
this.name = name;
this.scores= [
{subject:"html",scpres:"90"},
{subject:"JS",scpres:"90"},
]
}
Student.prototype.sex = "男";
Student.prototype.eat = function(food){
console.log("吃"+food)
}
var stu = new Student(1000,"张三");
stu.eat("米饭");
console.log(stu.sex);
var stu = new student(1000,"张三");

浙公网安备 33010602011771号