I have a method which sets a new instance to an array, created dynamically. How can I do that without the use of eval()?
var Form = (function(){
    function Form(params){
        this.shapesArray = [];
        this.shape;
        ...
    }
    Form.prototype.submit = function(){
        ... this.shape is the shape selected by the user ...
        this.setShape('new Shapes.' + this.shape + '(arg1, arg2, color)');
    }
    Form.prototype.setShape = function(obj){
        this.shapesArray.push(obj);
    }
return Form;
}());
So, how to call the setShape method by passing new instance to it without eval()?
This works so far:
Form.prototype.submit = function(){
    eval('this.setShape(new Shapes.'+ this.shape.capitalize() +'('+ str_params + '))');
}
But using eval() is not a good practice. How to achieve the same result wighout eval()?
 
    