Possible Duplicate:
How do I make JavaScript Object using a variable String to define the class name?
I want to be able to call the new
on things programmatically. So for example, if I have these two classes:
class Bird
constructor: (@name) ->
class Snake
constructor: (@name) ->
I can call s = new Snake("Sam")
. Now, what I want to do is
bird_class = "Bird"
b = new bird_class()
and be able to construct a bird object from a string. Is this possible in CoffeeScript or Javascript?