Menu
Hi All
Suppose I have the following class definition
[code]
MyClass = new Class() ;
MyClass.prototype = {
initialize: function(){},
// and other functions
}
Now I would like to create an instance, which you normally would do like
[code]
var obj = new MyClass() ;
but I have the class name in a variable:
[code]
var class_name = ‘MyClass’ ;
The question is now: using this variable, how do I create an instance. I’ve tried things like
[code]
var class_name = ‘MyClass’ ;
var obj = window[class_name]() ;
which, unfortunately, didn’t work ?
Any suggestions ?
thnx
LuCa