I'm working on a JavaScript object that looks like this:
var myObject = {
initialize: function() {
this.property1 = 'value 1',
this.property2 = 'value 2'
},
outer: {
inner: {
inner_property1: 'inner value 1',
inner_property2: 'inner value 2',
inner_property3: 'inner value 3',
inner_method: function(item1, item2) {
console.log(this.property1);
}
}
}
}
var instance = Object.create(myObject);
instance.initialize();
document.instance = instance;
I want to pass a variable set in the initialize method to the outer.inner.inner_method without adding more parameters to the method. However, the inner_method can only take two parameters as it is defined by a third party plugin. How can I access this.property1 from within the inner method?
Any suggestions would be greatly appreciated.