Creating modular class

I’m trying to make a class that can be extended by modules. All modules have same functions. When creating instance of class first parameter should be selected module name, like var test = new testClass(‘module1’);

So far I came up with following code:

// Variable to store modules list
var testClassModules = {};

// My test class
function testClass(mode) {
	this.mode = mode;
	this._modules = testClassModules;
	
	// Sample function
	this.testFunction = function() {
		// Do some global stuff here
		
		// Call module's function to do module specific stuff
		this._modules[this.mode].testFunction.call(this);
	};
};

// Test module #1
testClassModules['module1'] = {
	testFunction: function() {
		alert('Module #1. Mode = ' + this.mode);
	}
};

// Another test module
testClassModules['module2'] = {
	testFunction: function() {
		alert('This is second module. Mode = ' + this.mode);
	}
};

// Creating instance of test class, selecting first module
var test = new testClass('module1');
test.testFunction();

That code works fine, but I don’t like creating global variable for modules list. Is there a cleaner way to create similar code?

After thinking a bit more, I came up with a different solution that I think is cleaner:

function testClass() {
	this.mode = '';
	this.testFunction = function() {
		// Do some global stuff here
		this.localTestFunction();
	};

	// Initialize
	if (arguments.length > 0)
	{
		eval('var test = new testClass' + arguments[0].charAt(0).toUpperCase() + arguments[0].slice(1) + '();');
		return test;
	}
};

// Test module #1
function testClassModule1() {
	var that = new testClass();
	that.mode = 'module1';
	that.localTestFunction = function() {
		alert('Module #1. Mode = ' + this.mode); 
	};
	return that;
};

// Test module #2
function testClassModule2() {
	var that = new testClass();
	that.mode = 'module2';
	that.localTestFunction = function() {
		alert('This is second module. Mode = ' + this.mode); 
	};
	return that;
};

// Creating instance of test class, selecting first module
var test = new testClass('module1');
test.testFunction();


That code works fine too, but I don’t like using eval() to create module specific instance. Is there another way of creating class instance from string without using eval()?