私は最近Javascriptパターンを読んでいます.そして、シングルトンパターンについて話しているとき、私は以下のコードを理解していません:
function Universe(){
var instance;
Universe=function Universe(){
return instance;
};
Universe.prototype=this;
//the new Universe below,refers to which one?The original one,
//or the one:function(){return this;} ??
instance=new Universe();
instance.constructor=Universe;
instance.bang="Big";
return instance;
}
Universe.prototype.nothing=true;
var uni=new Universe();
Universe.prototype.everything=true;
var uni2=new Universe();
uni===uni2;//true