Skip to content

Instantly share code, notes, and snippets.

@guilhermepontes
Last active July 10, 2023 04:54
Show Gist options
  • Select an option

  • Save guilhermepontes/4504159 to your computer and use it in GitHub Desktop.

Select an option

Save guilhermepontes/4504159 to your computer and use it in GitHub Desktop.
var app;
app = (function(){
var myPrivateVariable = "my private content";
var application = {
init: function(){
console.log(myPrivateVariable);
},
cache: function() {
// impl
},
bind: function() {
// impl
},
blabla: function(){
// ....
}
}
return application;
})();
app.init(); // > my private content
app.myPrivateVariable // > undefined
@3emad
Copy link
Copy Markdown

3emad commented Jan 15, 2013

Thanks for sharing this, its awesome!

@albiere
Copy link
Copy Markdown

albiere commented Mar 8, 2014

I really like this approach!
However, I'd rather improve the public API in this case. Why are the functions "cache" and "bind" public?

What do you think?

@guilhermepontes
Copy link
Copy Markdown
Author

@albiere makes sense. Updated! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment