Is it possible to get a variable above the current scope in a Javascript object?
var object = {
access: [{
actionName: "Defending",
action: function(unit) {
}
}, {
actionName: "Mining",
action: function(unit) {
super.promises.push($interval(function() { // Here I need to access the variable 'promises' from the above scope
// do something
}, 1000));
}
}, {
actionName: "Cutting wood",
action: function(unit) {
super.promises.push($interval(function() { // Same here
// do something
}, 1000));
}
}],
promises: []
};
object.promises