Subj : Re: how to create an instance of class whose name is dynamic? To : Jun Yang From : Brendan Eich Date : Wed Aug 31 2005 06:27 pm Jun Yang wrote: > Hi all, > > I have something like below. > > function create(className) > { > return new ; > } > > Of course this is illegal in JavaScript. How can I create an instance > of a class whose name is dynamic? Several ways: 1. If the name is the value of a property in an object, you can say new obj[className] (or new obj[className](...) if there are arguments to pass). 2. Use eval. 1 is cheaper, so you should avoid this if you can. /be .