I'm facing a situation where I have a tree of closures: 'A' contains private closures 'pancake' and 'B'. There are times when I need to call the private closure 'pancake' from inside 'B' and access its public property. How can this be done? Oh, and it's worth mentioning that this is not an object.
Here's my code snippet:
var A = (function() {
var pancake = (function() {
return {
numeric: 142
};
})(A);
var B = (function() {
return {
init: function(name) {
console.log(pancake.numeric);
//How can I access the same element using the 'name' variable?
}
};
})(A);
return {
init: function() {
B.init('pancake');
}
};
})();
A.init();
For more details, check out JSFiddle: http://jsfiddle.net/yALkY/3/
Thank you in advance!