面向对象

一. 创建对象方式一 

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();
posted @ 2017-03-31 17:05  没有发条的橙  阅读(101)  评论(0编辑  收藏  举报