How can I do inheritance with this example.
I’m trying to create an object literal that functions as a singleton. Within this I’d like to extract my classes. Next to that, these classes should inherit from each other when applicable.
Like so:
var Singleton = {
car: function() {
this.engine= true;
},
ford: function() {
this.color = 'red';
}
};
I’d like to let ford inherit from bar, but I can’t do this:
ford: function() {
this.color = 'red';
this.prototype = new this.car();
}
Any ideas?
Here is a primer on inheritance