68
rated 0 times
[
75]
[
7]
/ answers: 1 / hits: 31363
/ 15 Years ago, fri, july 17, 2009, 12:00:00
I've seen this technique for calling a Javascript function based on the value of a string variable.
function foo() {
alert('foo');
}
var test = 'foo';
window[test](); //This calls foo()
Is this the accepted way to do it or is there a better way? Any cross-browser issues to worry about?
More From » function