And there is no native way to enforce that child objects are created with their own versions of these, right?
If you want all the instances to have those attributes, by default, then you should not inherit but construct them. The normal way to do this would be
function Parent(name, id) {
this.name = name;
this.id = id;
}
function Child(name, id) {
Parent.call(this, name, id);
}
Now, when you create an instance of Child
, they will have their own version of name
and id
. Also, you can assign values to them while creating them itself.