你的位置:首页 > Java教程

[Java教程]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();

单例模式