How to instantiate class using a variable in javascript

function MyClass() {}
MyClass.prototype.someFunc = function() {
  alert("Hello!");
};
var myClassName = "MyClass";
var myClassInstance = new window[myClassName]();
myClassInstance.someFunc();