Custom/Dynamic variable name
Hi,
In jquery variable, how can I have variable like below
- opts.[dynamic name]+'Func'
opts is an object variable inside function
- var opts = $.extend( options );
I can access with passed in variable name but in one of my case, I will be getting a [dynamic name] from another variable and I would like to check or access it.
- /* name "mobile" cannot be fixed as below statements will be checked within .each loop. Therefore "mobile" need to be dynamic. Got other name(s) may appear in the loop. */
- if (opts.mobileFunc) {
console.log('match function ');
- /* will be executing statement below */
- opts.mobileFunc.call(this);
}
I'm wondering How or is it possible to have such dynamic variable? This would allow me to create a more flexible function.
Thanks for any help and suggestions.