Answer the question
In order to leave comments, you need to log in
How to reference external js object from internal?
var out = {
in:{
f:function() {
//Здесь нужно получить ссылку на объект out а не in
}
}
}
Answer the question
In order to leave comments, you need to log in
This cannot be done without additional steps. If you really want parent, then you can do this:
var out = {
name: "OUT",
in: {
name: "IN",
f: function() {
console.log('in.name =', this.name);
console.log('in.parent.name =', this.parent.name);
}
},
init: function() {
this.in.parent = this;
return this;
}
}.init();
out.in.f();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question