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:
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?