For years I've been writing/extending my classes like so:
function Container(name, contents, logErrors){
this.name = name;
this.contents = contents;
this.logErrors = logErrors || false;
}
function Group(contents){
this.id = new Date().getTime();
Container.call(this, 'Group_'+ this.id, contents);
}
Group.prototype = Object.create(Container.prototype);
Group.constructor = Group;
and yet, in some places I've seen the constructor property being assigned on the prototype of the subclass rather than directly on the subclass:
function Group(contents){
this.id = new Date().getTime();
Container.call(this, 'Group_'+ this.id, contents);
}
Group.prototype = Object.create(Container.prototype);
Group.prototype.constructor = Group; // <-----
Which is correct?
a) Group.prototype.constructor = Group;
b) Group.constructor = Group;
c) both a AND b
d) neither a nor b
Please cite your source if possible.