var someModule = (function(){//private attributes var privateVar = 5; //private methods var privateMethod = function(){ return 'Private Test'; }; return { //public attributes publicVar: 10, //public methods publicMethod: function(){ return ' Followed By Public Test '; }, //let's access the private members getData: function(){ return privateMethod() + this.publicMethod() + privateVar; } } })(); //the parens here cause the anonymous function to execute and return someModule.getData();SOURCE: http://addyosmani.com/resources/essentialjsdesignpatterns/book/
programmer: a device to convert coffee into software
programmers: fixing other people's mistakes since 1908
programmer: are expected to know how to do things they've never done before
and estimate how long they will take
There are 10 types of people in this world. Those who know base 3, those who don't & those who expected a binary joke.
Samstag, 23. Juli 2011
JS Module Pattern
Abonnieren
Kommentare zum Post (Atom)
Keine Kommentare:
Kommentar veröffentlichen