面向对象
一. 创建对象方式一
function XiaCheng () {
this.name = 'xiacheng';
this.major = 'cs';
this.sex = 'man';
}
XiaCheng.prototype = {
showName : function(){
alert(this.name);
},
showMajor : function(){
alert(this.major);
},
showSex : function(){
alert(this.sex);
},
}
var xia = new XiaCheng();
xia.showName();
xia.showMajor();
xia.showSex();