Skip to content

Instantly share code, notes, and snippets.

@lwwcas
Created March 29, 2019 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lwwcas/f6382f060c6b4eacfbc139e3de6b1bd5 to your computer and use it in GitHub Desktop.
Save lwwcas/f6382f060c6b4eacfbc139e3de6b1bd5 to your computer and use it in GitHub Desktop.
Execute functions by name
function executeFunction(name, arg = ''){
let base = 'clear';
if (typeof window[base + name] === 'function') {
if (arg == '') {
return window[base + name](arg);
}
return window[base + name];
}
return false;
}
@andrepgsilva
Copy link

I love this code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment