I've got a JS object that looks like so:
return {
foo: function() {
return this.bar();
},
bar: function() {
return 1;
}
}
Why do I keep getting a TypeError: this.bar is not a function logged in FireBug? What's the proper way to reference the bar() method from foo() in the same object?
Update
So I've posted a fiddle with the whole code here. The return call is actually part of a RequireJS define. Let me know if any further clarification is required.
thisdepends on how you call it.