I'm trying to address a field of an object in javascript from within a function in another field like this:
var binds = {};
var name = 'hi';
binds[name] = {
foo: [],
bar: {
add: function (e) { foo.push (e); }
}
}
I tried this.foo.push (e)
and binding the function with .bind (binds[name])
and .bind (this)
but neither of those worked, how can I reference the foo
element from with a function in bar
?
EDIT:
I'm trying to reference a field which is not on the same object but higher up. So this is different from the linked question.