构造函数案例

来源:互联网 发布:mysql date add 1 day 编辑:程序博客网 时间:2024/06/01 20:13
//构造函数/也叫对象模板
function Student(){
this.sname=sname;
this.sage=sage;
this.intrSelf=function(){
dialog.innerHTML="I'm "+this.sname+"+,I'm "+this.sage;
dialog.style.display="block";
}
}
//Step2:用new调用构造函数,传入属性值
var lilei=new Student("Li Lei",18);
var hmm=new Student("Han Meimei",19);
0 0
原创粉丝点击