设计模式需要掌握的代码

"Hello World, Hello Blog"

Posted by wudimingwo on December 15, 2018

单例模式

1
2
3
4
5
6
7
8
9
function getSingle (fun) {
              	var instance;
              	return function () {
              		if(!instance){
              		  instance = fun.apply(this,arguments);
              		}
              		return instance;
              	}
              }