If I have The code:
function RandomObjectThatIsntNamedObjectWhichIOriginallyNamedObjectOnAccident() {
this.foo = 0;
this.bar = function () {
this.naba = function () {
//How do I reference foo here?
}
}
}
You need a self
reference:
function RandomObjectThatIsntNamedObjectWhichIOriginallyNamedObjectOnAccident() {
var self = this;
this.foo = 0;
this.bar = function () {
this.naba = function () {
self.foo; //foo!
}
}
}
function SomeObject() {
var self = this;
this.foo = 0;
this.bar = function () {
this.naba = function () {
self.foo;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With