Reputation: 168199
Having the function name 'foo' and its argument 'arg' in strings, is there a way to execute foo(arg)? Do I need to use eval? I want to do something like send(foo, arg) if it were in Ruby.
'foo'
'arg'
foo(arg)
eval
send(foo, arg)
Upvotes: 2
Views: 54
Reputation: 887777
You can use indexer notation:
window[name](arg);
Upvotes: 4