I’ve tried myriads of ways to create new class instances dynamically, without using eval and hard coded key-value pairs, to no avail. Seemingly there is no way in modern Javascript to query the user defined classes and/or to create them. Is there any remedy to my problem?
Example:
class Whatever {}
class Anything {}
classes = {Whatever, Anything}
//These ofc doesn't work
instance = new ['Whatever']()
instance = new window['Whatever']()
//This works, but eval...
x = eval('Whatever')
instance = new x()
//This also works, but with mapping, not nice
new window['classes']['Whatever']()