JavaScript provides prototype inheritance. Objects do inherit from other objects. This can be fine for method inheritance, but it does not work for properties inheritance.
Typically to inherit methods you could use:
function BaseViewModel() {
var self = this;
self.name = ko.observable();
}
function Person() {
var self = this;
self.firstname = ko.observable();
}
Person.prototype = new BaseViewModel();
But that causes all the persons to share the same object as prototype! When you change the name for one person, the value get's propagated to all the Persons. I tend to use the jQuery's extend method.
function Person() {
var self = this;
$.extend(self, new BaseViewModel());
self.firstname = ko.observable();
}
This way the values from BaseViewModel get copied to Person.