Call function in string javascript
1. Using eval
var strFun1 = "func1";
var ret1 = eval(strFun1);
ret1(1,2,3);
function func1(a,b,c){
alert(a);
alert(b);
alert(c);
}
1. Using Window property (Recommend)
var strFun2 = "func2";
window[strFun2](parmas);
function func2(data){
console.info(data);
}
No comments:
Post a Comment