The issue I have is that I am trying to construct an object in JavaScript, but I don't know what the object will be until runtime.
My code looks something like this:
var modelType = attrs.type;
return new modelType();
attrs.type will contain the name of a valid constructor. So for instance, it might be book, cat or dog. Depending on whatever it is, I want to construct that object. I cannot test what attrs.type is first and then choose the correct constructor because the types might change at any time in the future.
Currently the error I am getting is: Uncaught TypeError: string is not a function. (Since modelType is a string...)
Any help would be greatly appreciated!