Skip to content

Instantly share code, notes, and snippets.

@yangjunjun
Created October 28, 2013 07:02
Show Gist options
  • Save yangjunjun/7192440 to your computer and use it in GitHub Desktop.
Save yangjunjun/7192440 to your computer and use it in GitHub Desktop.
设计模式-单例模式 http://blog.jobbole.com/29454/
var singleton = function( fn ){
var result;
return function(){
return result || ( result = fn .apply( this, arguments ) );
}
}
var createMask = singleton( function(){
return document.body.appendChild( document.createElement('div') );
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment