Skip to content

Instantly share code, notes, and snippets.

@bgadrian
Created March 16, 2015 17:24
Show Gist options
  • Save bgadrian/e2172ddb997aa0ac9aa3 to your computer and use it in GitHub Desktop.
Save bgadrian/e2172ddb997aa0ac9aa3 to your computer and use it in GitHub Desktop.
JS call a function from a string
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