var single = (function(){
var unique;
function getInstance(){
if( unique === undefined ){
unique = new Construct();
}
return unique;
}
function Construct(){
// ... 生成单例的构造函数的代码
}
return {
getInstance : getInstance
}
})();
转载于:https://my.oschina.net/u/1992917/blog/413263