Is there a shorter way to write this:
var controller = function(){
/*--- constructor ---*/
};
controller.prototype.function1 = function(){
//Prototype method1
}
controller.prototype.function2 = function(){
//Prototype method2
}
controller.prototype.function3 = function(){
//Prototype method3
}
return controller
I'm using require.js. I wondered if I can avoid the controller.prototype code repetition.
With a Helper Function
Even though this is longer than the answer given if you have to do this multiple places might be helpful to define a helper method:
Using jQuery's extend method
I thought I should mention jQuery's extend method because it was brought up in a comment and because in general has more functionality than the small helper method defined in the first part of the answer:
Other Libraries
Other libraries also have similar functionality built in, such as underscore's extend method or Lo-Dash's assign method
Object.assign(controller.prototype, { function1: ... })