js定义类对象、属性和方法

阅读更多
var provinces = new Array();
comefrom.prototype.loca = null;
comefrom.prototype.locacity = null;
comefrom.prototype.abbreviation = null;
function comefrom(loca,locacity,abbreviation) { this.loca = loca; this.locacity = locacity; this.abbreviation = abbreviation}
provinces[0]= new comefrom("请选择省份名","请选择城市名");
provinces[1] = new comefrom("上海市","|上海市","沪");
provinces[2] = new comefrom("北京市","|北京市","京");
provinces[3] = new comefrom("江苏省","|南京市|苏州市","苏");
provinces[4] = new comefrom("广东省","|广州市|珠海市|汕头市|佛山市|韶关市|湛江市|肇庆市|江门市|茂名市|惠州市|梅州市|汕尾市|河源市|阳江市|清远市|东莞市|中山市|潮州市|揭阳市|云浮市|顺德","粤");
provinces[5] = new comefrom("福建省","|福州市|莆田市|泉州市|厦门市|漳州市|龙岩市|三明市|南平市|宁德市","闽");


/**
 * 初始化页面
 * @return void
 */
pageInit : function() {
	var provinceList = new Array();
	var hiddenProvinces = _STAGE.hiddenProvinces;
	for(i = 1;i < provinces.length; i++){
		var loca = provinces[i].loca;
		provinceList.push('
  • '+loca+'
  • '); } },

     

    result:
    comefrom {loca: "上海市", locacity: "|上海市", abbreviation: "沪", loca: null, locacity: null…}
    abbreviation: "沪"
    loca: "上海市"
    locacity: "|上海市"

     

    你可能感兴趣的:(乔乐共享,纵观千象,js,class,prototype)