0

Goal is to be able to allow a global variable (such as currentAccount) to refer to multiple values at the same time based on the execution context.

var context = new Context();
context.currentAccount = "mine";
context.execute(function() {
   // any code in or called by this function 
   // needs access to the `currentAccount` variable

   // for example
   var model = new Model();
   model.doSomething(); // model needs to be able to refer to `currentAccount`
});

context = new Context();
context.currentAccount = "yours";
context.execute(function() {
   ...
   model.doSomething(); // `currentAccount` => "yours"
});
4

0 回答 0