87,902
社区成员
发帖
与我相关
我的任务
分享
var xtComm = (function () {
var Coord = (function () {
var __type = "";
var ctor = function (type) {
/*this.*/__type = type; //不能用this,要不Calc也要通过this来调用
}
var proto = ctor.prototype;
proto.Calc = function (n1, n2) {
var result = 0;
if (__type == "add") {
result = n1 + n2;
}
return result;
};
return ctor;
})();
return { Coord: Coord };
/* xtComm.Coord = Coord;//不能这样引用xtComm,会报错,xtComm都还没初始化
return xtComm;*/
})();
var comm = new xtComm.Coord("Add");
alert(comm.Calc(1, 43))