Forum Moderators: open
var test = {
var1: {varx: null, vary: null},
method1: {
submeth1: function (x) {
this.var1.varx = x'
}
submeth2: function() {
return this.var1.varx;
}
},
get_varx: function () {
return this.var1.varx;
}
}
test.method1.submeth1('my new value'); // the value
console.log(test.method1.submeth2()); // null
console.log(test.get_varx()); // null
var test = {
var1: {
varx: null,
vary: null
},
method1: {
submeth1: function (x) {
console.log(this);
this.var1.varx = x;
},
submeth2: function () {
console.log(this);
return this.var1.varx;
}
},
get_varx: function () {
return this.var1.varx;
}
}
test.method1.submeth1.call(test,'my new value '); // the value
console.log(test.method1.submeth2.call(test)); // my new value
console.log(test.get_varx()); // my new value