javascript, design patterns, type pattern
// Type Pattern
<package>.T = (function () {
var T = {};
// Shared properties and methods go here
T.create = function (…) {
vart = Object.create(this);
// Assign the own properties here
return t;
}
return T;
}());
// Instantiate with: varx = <package>.T.create(…);
// The "type" object and the prototype are one!
// Differs from operator new, which equates the type with the constructor (prototype separate)