, "--prototype" -idea: - ( , ), , , ; " " ( , ).
, . , , , ( this.Subscription). , .
, :
function Class() {
this.Subscription = function(args) {
this.propertyTwo = {
subprop: args.something
};
};
this.Subscription.prototype = {
property_one: "value",
property_two: {}
};
}
Class.prototype.get_subscription = function(args) {
return new this.Subscription(args);
}
:
var object = new Class();
var sub = new object.Subscription();
var sub2 = new object.Subscription();
// the promised boost is less memory usage for:
sub.propertyOne === object.Subscription.prototype.propertyOne === sub2.propertyOne;
Prototypal inheritance Crockford - // propertyTwo -Object (s).