lundi 22 juin 2015

Local vars javascript module pattern

How can I refere to a local variable inside a private function? For example, in the next code, in function myDisplay how can I get the object myObject of show function object and obtain id = 'B'?

var charge() = (function($){

    var open = function(){
        var myObj = {
            id: 'A'
        }
    }

    var show = function(){
        var myObj = {
            id: 'B'
        }
        myDisplay();
    }

    function myDisplay(){
        //Here, how to refer to var myObj of show function object?
    }
    var ret = {
        open: open,
        show: show
    }
    return ret;
})(jQuery);

Aucun commentaire:

Enregistrer un commentaire