Newbie to JavaScript here.
How do I reference member foo
from within member foobar
, given that foobar
's in a closure?
var priv = {
foo: "bar",
foobar: (function() {
return this.foo === "bar";
})()
};
The code above fails. In it, this.foo
is undefined
. If I change this.foo
to priv.foo
, it's still undefined
. How do I reference priv.foo
from within the foobar
closure?