Call javascript function from string name
var strFunc = "myFunc";
var strParam = "functionParameter"
//Create the function
var func = window[strFunc];
//Call the function
func(strParam);
Written by Quoc Toan
Related protips
3 Responses
Maybe elaborate what's going on here? maybe a less cryptic example?
over 1 year ago
·
Why would you even do that?
over 1 year ago
·
We can use it in case we need to dynamically call function.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#