Created
March 11, 2013 05:13
-
-
Save kazu69/5132032 to your computer and use it in GitHub Desktop.
Dynamic function names in JavaScript
ref http://marcosc.com/2012/03/dynamic-function-names-in-javascript/
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
"use strict"; | |
var name = "foo"; | |
var func = new Function( | |
"return function " + name + "(){ alert('sweet!')}" | |
)(); | |
//call it, to test it | |
func(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment