js模式(一):单例模式

 

function Universe(){
         var instance;
         Universe = function (){
             return instance;
         }
         Universe.prototype = this;
         console.log(Universe);
         instance = new Universe();
         instance.constructor = Universe;

         instance.start_time = 0;
         instance.bng ="dd";
         return instance;
     }

     Universe.prototype.nothint = 1;
      console.log(Universe);
     var a = new Universe();
 console.log(Universe);
     var b = new Universe();

单例模式

posted on 2015-04-29 22:56  dhj  阅读(183)  评论(0编辑  收藏  举报

导航