I would like to handle undefined properties and/or identifiers on my object before they fail/return undefined if that is possible.
Is there a neat way to capture the access to a non-defined property and handle it without using try/catch?
var myObj = {
myVar : 10,
myFunc : function(){console.log('foo')
}
myObj.myVar;
myObj.myFunc();
var x = "myFunc";
myObj[x];
x = "myOtherFunc";
// Handle this in an eventhandler or similar before it fails!?!?
myObj[x];
I can not alter the calling code from my position. I can only change the code inside myObj, since its a module used by others.