Given following JavaScript code:
({
foo: 1,
bar: 2,
zoo: 3,
test: function(i) {
var g = function(i) {
alert(i + zoo);
}
g(i);
}
}).test(2);
Why is zoo undefined in alert()? Which kind of syntax can I use to correctly reference to zoo and get alert display for value 5?
Update: I would prefer solution where only implementation of g needs to change, if at all possible.