In a recent project, I found myself using the following code:
function foo(type, desc)
{
var p = new type(desc);
}
Although I am not a JavaScript expert, it seems to be functioning properly in Chrome. Can anyone confirm if this is valid JavaScript?
The 'type' variable represents a class that extends another class and contains some functions, while 'desc' is simply an object holding properties.
Update: It has been confirmed that 'type' is indeed a constructor: function type(desc) {}