0

I am new to requirejs and don't understand variable scope.

So previously, for example, I had:

var Foo = "some value";

function firstFunction () {

    //do something with Foo here
    console.log(Foo); 

    }


 function secondFunction () {

    //do something else with Foo here
    console.log(Foo); 

    }

But within a module

define(function() {

   return {

      //how do I declare Foo within the module so it is available to firstFunction and secondFunction?

      firstFunction: function() {
          //do something with Foo here
          console.log(Foo);
          },

      secondFunction: secondFunction () {
         //do something else with Foo here
         console.log(Foo);
         }
     }

    });

Is there a way of declaring the variable Foo within the module and to make it available to firstFunction() and secondFunction()?

mssbcons
  • 25
  • 3

0 Answers0