I don’t really know the correct words to describe what I am trying to do, but the functionality is very similar to overriding the __get() function of PHP classes. For example this is what I want to do.
var obj = {
param1:'a',
func1:function(){ return '1';},
catch_all:function(input){
return input;
}
}
//alerts 'a'
alert( obj.param1 );
//alerts '1'
alert( obj.func1() );
//alerts 'anything'
alert( obj.anything );
Basically I want a way to redirect any unused key to a predefined key. I have done some research on this and really didn’t know what to search for. Any help is greatly appreciated. Thanks.
This is impossible with the current JavaScript implementations. There is not any kind of default getter as you have in ObjC or other languages.