Контекст
From an instance context:
function A() { this.getClass = function() { return window[this.constructor.name]; } this.getNewInstance = function() { return new window[this.constructor.name]; } } var a = new A(); console.log(a.getClass()); // function A { // etc... } // you can even: var b = new a.getClass(); b instanceof A; // true
From static context:
function B() {}; B.getClass = function() { return window[this.name]; } B.getInstance() { return new window[this.name]; }