Is there a way to access the Parent's attribute from inner() without its reference being passed explicitly to it (as I have to do in this code) ?
Here is my javascript code :
function Parent() {
return {
outer: {
parent: null, //I want to avoid this
name: 'outer',
inner: function() {
console.log(this.name);
console.log(this.parent.name); //how to access parent.name ?
}
},
name: 'parent'
};
}
$(document).ready(function() {
var p = new Parent();
p.outer.parent = p; //I want to avoid this
p.outer.inner();
});