Friday 14 April 2017

CommonJS function declaration scope good practice

Is there a good practice for where you declare a function inside a CommonJS module in a case like this:

// function foo() { ... }

module.exports = function () {
   // function foo () { ... }

   return function () {
        // function foo () { ... }

        return foo();
   };
};

Where should function foo {} go ? Of course I'm assuming you really have the choice between the 3 possibilities in your module code and that all of them would work properly as intended.



via fabmlk

No comments:

Post a Comment