Created
May 11, 2010 15:47
-
-
Save andyfowler/397454 to your computer and use it in GitHub Desktop.
This file contains 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
var className = 'Graph' + type; | |
// lesser of two uglies? | |
var graph = new window[className](this); | |
// versus | |
var graph = eval('new ' + className + '(this)'); | |
// using window makes sanity checking easier: | |
if (typeof window[className] === 'function') // instantiate ... | |
// versus | |
if (eval('typeof ' + className) === 'function') // instantiate ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment