Javascript: Using a variable as a constructor name

Viewed 1474

I need to take a parameter from another function which will then be used as the name of the constructor for a new instance of an object:

function foo(bar) {
    thing.push(new bar(arg1, arg2);
}

How do I create a new instance of an object which is constructed by the value of bar, where bar is a string?

2 Answers
Related