Javascript 5 Module Pattern internal name

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












I'm learning about the Javascript module pattern from an array of online sources. The following suits my basic needs at the moment:



var module = function()

// Create the return module and its configuration
var module = ,
config =
css:
classes:
heading:'h1',
navbar:'nav-bar'
,
ids:
widget:'widget',
block:'block'

,
userName:'user',
token:'UUID'
;

// Private methods
function _moduleMethod()
console.log(config.userName);


// Add functionality to the module's init()-ialising method
function init()
_moduleMethod();


// Add init, and any other methods, to obj
module["init"] = init;

// Return a the module as a Public API
return module;

();

// When the DOM is ready, run the module
document.addEventListener("DOMContentLoaded", function()
module.init();
);


My question is regarding the naming of the internal return object the same as the external variable "module". My thinking is that it's OK given closure and scoping but most of the examples I've seen name the internal object something like "obj" or "my". Am I going to run into issues down the line, say with the Augmenting module pattern?







share|improve this question

























    up vote
    0
    down vote

    favorite












    I'm learning about the Javascript module pattern from an array of online sources. The following suits my basic needs at the moment:



    var module = function()

    // Create the return module and its configuration
    var module = ,
    config =
    css:
    classes:
    heading:'h1',
    navbar:'nav-bar'
    ,
    ids:
    widget:'widget',
    block:'block'

    ,
    userName:'user',
    token:'UUID'
    ;

    // Private methods
    function _moduleMethod()
    console.log(config.userName);


    // Add functionality to the module's init()-ialising method
    function init()
    _moduleMethod();


    // Add init, and any other methods, to obj
    module["init"] = init;

    // Return a the module as a Public API
    return module;

    ();

    // When the DOM is ready, run the module
    document.addEventListener("DOMContentLoaded", function()
    module.init();
    );


    My question is regarding the naming of the internal return object the same as the external variable "module". My thinking is that it's OK given closure and scoping but most of the examples I've seen name the internal object something like "obj" or "my". Am I going to run into issues down the line, say with the Augmenting module pattern?







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm learning about the Javascript module pattern from an array of online sources. The following suits my basic needs at the moment:



      var module = function()

      // Create the return module and its configuration
      var module = ,
      config =
      css:
      classes:
      heading:'h1',
      navbar:'nav-bar'
      ,
      ids:
      widget:'widget',
      block:'block'

      ,
      userName:'user',
      token:'UUID'
      ;

      // Private methods
      function _moduleMethod()
      console.log(config.userName);


      // Add functionality to the module's init()-ialising method
      function init()
      _moduleMethod();


      // Add init, and any other methods, to obj
      module["init"] = init;

      // Return a the module as a Public API
      return module;

      ();

      // When the DOM is ready, run the module
      document.addEventListener("DOMContentLoaded", function()
      module.init();
      );


      My question is regarding the naming of the internal return object the same as the external variable "module". My thinking is that it's OK given closure and scoping but most of the examples I've seen name the internal object something like "obj" or "my". Am I going to run into issues down the line, say with the Augmenting module pattern?







      share|improve this question











      I'm learning about the Javascript module pattern from an array of online sources. The following suits my basic needs at the moment:



      var module = function()

      // Create the return module and its configuration
      var module = ,
      config =
      css:
      classes:
      heading:'h1',
      navbar:'nav-bar'
      ,
      ids:
      widget:'widget',
      block:'block'

      ,
      userName:'user',
      token:'UUID'
      ;

      // Private methods
      function _moduleMethod()
      console.log(config.userName);


      // Add functionality to the module's init()-ialising method
      function init()
      _moduleMethod();


      // Add init, and any other methods, to obj
      module["init"] = init;

      // Return a the module as a Public API
      return module;

      ();

      // When the DOM is ready, run the module
      document.addEventListener("DOMContentLoaded", function()
      module.init();
      );


      My question is regarding the naming of the internal return object the same as the external variable "module". My thinking is that it's OK given closure and scoping but most of the examples I've seen name the internal object something like "obj" or "my". Am I going to run into issues down the line, say with the Augmenting module pattern?









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jan 18 at 2:59









      sansSpoon

      1234




      1234




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Because of the scoping inside a closure you will not run into a problem.



          The Revealing Module Pattern



          I want to introduce this type of module pattern because it does not need the helper object module. Instead of collecting all public functions inside an object called module return directly an object with all public functions. This will reduce code and result in a better to reading code.



          var module = function () 
          var config =
          css:
          classes:
          heading: 'h1',
          navbar: 'nav-bar'
          ,
          ids:
          widget: 'widget',
          block: 'block'

          ,
          userName: 'user',
          token: 'UUID'
          ;

          function _moduleMethod()
          console.log(config.userName);


          function init()
          _moduleMethod();


          // Return an object as public API
          return
          init: init

          ();





          share|improve this answer





















            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "196"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f185362%2fjavascript-5-module-pattern-internal-name%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            Because of the scoping inside a closure you will not run into a problem.



            The Revealing Module Pattern



            I want to introduce this type of module pattern because it does not need the helper object module. Instead of collecting all public functions inside an object called module return directly an object with all public functions. This will reduce code and result in a better to reading code.



            var module = function () 
            var config =
            css:
            classes:
            heading: 'h1',
            navbar: 'nav-bar'
            ,
            ids:
            widget: 'widget',
            block: 'block'

            ,
            userName: 'user',
            token: 'UUID'
            ;

            function _moduleMethod()
            console.log(config.userName);


            function init()
            _moduleMethod();


            // Return an object as public API
            return
            init: init

            ();





            share|improve this answer

























              up vote
              1
              down vote













              Because of the scoping inside a closure you will not run into a problem.



              The Revealing Module Pattern



              I want to introduce this type of module pattern because it does not need the helper object module. Instead of collecting all public functions inside an object called module return directly an object with all public functions. This will reduce code and result in a better to reading code.



              var module = function () 
              var config =
              css:
              classes:
              heading: 'h1',
              navbar: 'nav-bar'
              ,
              ids:
              widget: 'widget',
              block: 'block'

              ,
              userName: 'user',
              token: 'UUID'
              ;

              function _moduleMethod()
              console.log(config.userName);


              function init()
              _moduleMethod();


              // Return an object as public API
              return
              init: init

              ();





              share|improve this answer























                up vote
                1
                down vote










                up vote
                1
                down vote









                Because of the scoping inside a closure you will not run into a problem.



                The Revealing Module Pattern



                I want to introduce this type of module pattern because it does not need the helper object module. Instead of collecting all public functions inside an object called module return directly an object with all public functions. This will reduce code and result in a better to reading code.



                var module = function () 
                var config =
                css:
                classes:
                heading: 'h1',
                navbar: 'nav-bar'
                ,
                ids:
                widget: 'widget',
                block: 'block'

                ,
                userName: 'user',
                token: 'UUID'
                ;

                function _moduleMethod()
                console.log(config.userName);


                function init()
                _moduleMethod();


                // Return an object as public API
                return
                init: init

                ();





                share|improve this answer













                Because of the scoping inside a closure you will not run into a problem.



                The Revealing Module Pattern



                I want to introduce this type of module pattern because it does not need the helper object module. Instead of collecting all public functions inside an object called module return directly an object with all public functions. This will reduce code and result in a better to reading code.



                var module = function () 
                var config =
                css:
                classes:
                heading: 'h1',
                navbar: 'nav-bar'
                ,
                ids:
                widget: 'widget',
                block: 'block'

                ,
                userName: 'user',
                token: 'UUID'
                ;

                function _moduleMethod()
                console.log(config.userName);


                function init()
                _moduleMethod();


                // Return an object as public API
                return
                init: init

                ();






                share|improve this answer













                share|improve this answer



                share|improve this answer











                answered Jan 19 at 7:30









                Roman

                20517




                20517






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f185362%2fjavascript-5-module-pattern-internal-name%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Chat program with C++ and SFML

                    Function to Return a JSON Like Objects Using VBA Collections and Arrays

                    Will my employers contract hold up in court?