Why not try this?
var MODULE = (function () {
var my = {};
my.SomeClass = SomeClass;
function SomeClass(six) {
this.six = six;
}
SomeClass.prototype.five = 5;
return my;
})();
When you call var obj = new MODULE.SomeClass(6)
it will give you a new object. obj.five
is shared between all instances of SomeClass
because it is attached to the prototype. However, obj.six
is specific to that instance, because it is attached to obj
.
Alternatively, you may not need for your class to be inside a module. You could use a class to replace the module where appropriate, because both modules and classes in this case have some overlapping functionality.