目標は、グローバル変数 ( などcurrentAccount
) が実行コンテキストに基づいて同時に複数の値を参照できるようにすることです。
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"
});