Create a gist now

Instantly share code, notes, and snippets.

var app = (function(w, d){
var myPrivateVariable = "My private content";
var __private = {
cache : function(){ = d.querySelector('.link-item');
bind : function(){'click', this.handleClick, false);
handleClick: function(){
var app = {
init: function(){
return app;
})(window, document);
app.init(); //init the app
console.log(myPrivateVariable); // undefined
3emad commented Jan 15, 2013

Thanks for sharing this, its awesome!

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?


@albiere makes sense. Updated! :)

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