Mat*_*att 65
您可以检查它是否在全局范围内定义;
if (typeof window[strOfFunction] === "function") {
// celebrate
//window[strOfFunction](); //To call the function dynamically!
}
Run Code Online (Sandbox Code Playgroud)
小智 6
你可以使用eval:
if ( eval("typeof stringFunction === 'function'") ){ /*whatever*/ }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18096 次 |
| 最近记录: |