YES...
However, it is strange that you create a named function, but you never reference it by name.
The more common patterns I've seen
function MyClass(){
this.val = 5;
};
MyClass.prototype.getValue = function() {
return this.val;
}
MyClass = new MyClass();
But when people do this, I wonder why they don't just use a literal object
var MyClass = {
val: 5,
getValue: function() {
return this.val;
}
}
And I would even rather use the module template here
var MyClass = (function(){
var val = 5;
return {
getValue: function() {
return val;
}
};
})();
Renouncement
, singleton, ( , , , , )