Custom/Dynamic variable name

Custom/Dynamic variable name

Hi,

In jquery variable, how can I have variable like below

  1. opts.[dynamic name]+'Func'

opts is an object variable inside function

  1. 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.

  1. /* 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. */
  2. if (opts.mobileFunc) {
          console.log('match function ');
  3.       /* will be executing statement below */
  4.       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.