I have a number of JavaScript \"classes\" each implemented in its own JavaScript file. For development those files are loaded individually, and for production they are conca
As an addition to jrburke's answer, note that you don't have to return the constructor function directly. For most useful classes you'll also want to add methods via the prototype, which you can do like this:
define('Employee', function() {
// Start with the constructor
function Employee(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
// Now add methods
Employee.prototype.fullName = function() {
return this.firstName + ' ' + this.lastName;
};
// etc.
// And now return the constructor function
return Employee;
});
In fact this is exactly the pattern shown in this example at requirejs.org.