您可以尝试:
var newInstance = Object.create(window[className].prototype);newInstance.constructor.apply(newInstance, instanceparameters);return newInstance;
编辑 此版本可在Typescript操场上使用,例如:
class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting; }}//instance creation herevar greeter = Object.create(window["Greeter"].prototype);greeter.constructor.apply(greeter, new Array("World"));var button = document.createElement('button');button.innerText = "Say Hello";button.onclick = function() { alert(greeter.greet());}document.body.appendChild(button);


