How can I access a property
from inside an object
? Manually entering its path allows me to retrieve the property, but not when attempting to do it dynamically.
What am I missing in the code snippet below?
var myApp = {
cache : {},
init: function() {
myApp.cache.akey = 'A value'; // Set the cached value
myApp.get('cache', 'akey');
},
get: function(from, key ) {
console.log(myApp.from.key); // undefined
console.log(myApp.cache.akey); // A value
}
};