You can use call()
or apply()
each time you call your function, to choose which value you want this
to have;
function C_page() {
this.errors = [];
function void_log_str(L_message) {
this.errors.push(L_message);
}
void_log_str.call(this, "value_of_l_message");
}
... or you can use bind()
to force the value of this (benefits of this is that you do this in the definition, not in the invokation);
function C_page() {
this.errors = [];
var void_log_str = function(L_message) {
this.errors.push(L_message);
}.bind(this);
void_log_str("value of l message");
//and more code...
}
... or you can use the var that = this
approach;
function C_page() {
var that = this;
this.errors = [];
function void_log_str(L_message) {
that.errors.push(L_message);
}
void_log_str("value of l message");
//and more code...
}