Contents tagged with module

  • Module and revealing module design patterns in Javascript

    Hello everybody,

    today I want to propose you interesting comparison of two design patterns in javascript.  As you probably know, javascript doesn't have idea of public and private members. So in order to implement them some tricks are used. That is module and "revealing module".

    Take a look at samples of them:

    Module

    Revealing module

    var md = ( function(){

     var privateMember = “private”;

    return {

                publicMember : “publicMember”

            };

    }

    )();

    var md = ( function(){

     var privateMember = “private”;

     var publicMember = “publicMember”;

    return {

                publicMember : “publicMember”

    };

    }

    )();

    The difference is where are … more