Skip to content

Instantly share code, notes, and snippets.

@lexeek
Forked from guilhermepontes/module-es2015.js
Created May 13, 2016 11:03
Show Gist options
  • Save lexeek/66583b60dc795e4dd17b4e8ba2043de9 to your computer and use it in GitHub Desktop.
Save lexeek/66583b60dc795e4dd17b4e8ba2043de9 to your computer and use it in GitHub Desktop.
var app = (function(w, d){
var myPrivateVariable = "My private content";
var __private = {
cache : function(){
this.link = d.querySelector('.link-item');
}
bind : function(){
this.link.addEventListener('click', this.handleClick, false);
},
handleClick: function(){
console.log(myPrivateVariable);
}
};
var app = {
init: function(){
console.log(myPrivateVariable);
__private.cache();
__private.bind();
}
};
return app;
})(window, document);
app.init(); //init the app
console.log(myPrivateVariable); // undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment