Created
October 28, 2013 07:02
-
-
Save yangjunjun/7192440 to your computer and use it in GitHub Desktop.
设计模式-单例模式 http://blog.jobbole.com/29454/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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