Created
March 16, 2015 17:24
-
-
Save bgadrian/e2172ddb997aa0ac9aa3 to your computer and use it in GitHub Desktop.
JS call a function from a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj.functionName = "myCall"; | |
var fn = window[obj.functionName]; | |
if(typeof fn === 'function') { | |
fn(params); | |
} | |
function myCall() {} | |
//works for objects too, instead of window = your own instance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment