Skip to content

Instantly share code, notes, and snippets.

@yuguo
Created April 12, 2012 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuguo/2365663 to your computer and use it in GitHub Desktop.
Save yuguo/2365663 to your computer and use it in GitHub Desktop.
单例模式
(function(){
var name = 'Chris';
var age = '34';
var status = 'single';
function createMember(){
// [...]
}
function getMemberDetails(){
// [...]
}
})();
var myApplication = function(){
var name = 'Chris';
var age = '34';
var status = 'single';
function createMember(){
// [...]
}
function getMemberDetails(){
// [...]
}
return{
create:createMember,
get:getMemberDetails
}
}();
//myApplication.get() and myApplication.create() now work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment