I ended up with this code in one of my projects:
function foo(type, desc)
{
var p = new type(desc);
}
I am not an expert in JS, can somebody confirm whether it’s valid JavaScript or not? It seems to be working fine, with Chrome at least.
type – is a class that is derived from another class, has some functions.
desc – is just an object that keeps properties.
update: yes, type is a constructor: function type(desc) {}
assuming
var type = function(foo){...}then yes