This question was already asked and answered here.
Unfortunately it seems that this does not work with a ES6 classes.
Relevant Code of the classes involved:
class ORM {
construct() {
let className = 'Task';
new this[className]; //throws: ORM.js:25 Uncaught TypeError: this[className] is not a constructor
new window[className]; //throws: ORM.js:26 Uncaught TypeError: window[className] is not a constructor
new this[className](1); //throws: ORM.js:27 Uncaught TypeError: this[className] is not a constructor
new window[className](1); //throws: ORM.js:28 Uncaught TypeError: window[className] is not a constructor
}
}
class Task extends ORM {
constructor(id = null) {}
}
Is there any equivilant for ES6? Am I just missing something?
And no I would like to not use eval. Except if it is my last resort.