var Person = (function(){
var Constr;
Constr = function(){
this.name = ‘carl‘;
}
Constr.prototype = {
constructor : Constr,
getName : function(){
return this.name;
}
}
return Constr;
}())
var obj = new Person();
console.log(obj.getName()); //输出:carl
javascript构造函数模块,布布扣,bubuko.com
原文:http://www.cnblogs.com/fengzekun/p/3892479.html