javascript构造函数模块

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

posted @ 2014-08-05 15:59  ZeKun  阅读(204)  评论(0编辑  收藏  举报