1

I have the same question that: Calling dynamic function with dynamic parameters in Javascript

But, with a little change: I need to call a function, and send a parameter dinamically.

Let's suppouse:

var fun = 'theFunction';
var value = '123';

I can run it properly doing:

window[fun].apply(null, [value]);

But, what if my function is:

var fun = 'someNamespace.utils.theFunction';

If I do:

window[fun].apply(null, [value]);

I get:

TypeError: window[fun] is undefined

What can i Do to solve that issue?

Community
  • 1
  • 1
Broda Noel
  • 1,760
  • 1
  • 19
  • 38

0 Answers0