Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.