I have this example code:
var foo = { self: this, init: function(){ self.doStuff(); }, doStuff: function(){ alert(\'doing
The value of this is determined by how the current function was called. It does not refer to the current object.
this
This will work:
var foo = { init: function(){ this.doStuff(); }, doStuff: function(){ alert('doing stuff'); } }; foo.init();
Since when you call foo.init(), this becomes foo.
foo
.init()