Skip to content

Instantly share code, notes, and snippets.

@joelpalmer
Last active August 29, 2015 14:22
Show Gist options
  • Save joelpalmer/40b5d35ad569b057a3fa to your computer and use it in GitHub Desktop.
Save joelpalmer/40b5d35ad569b057a3fa to your computer and use it in GitHub Desktop.
Avoid eval if you have a name of an object's function in a string and use array syntax to call it
var funcName = "myfunc";
var thingy = {age:27,
myfunc: function fun() {
console.log("It worked")
}};
thingy[funcName]();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment