var singleton = (function(){ var instance; return function () { if (instance) return instance; instance = this; return instance; } }()); var obj = new singleton(); var obj2 = new singleton(); console.log(obj2 === obj); // true
原文:http://www.cnblogs.com/ax-null/p/6789316.html