I am trying to do some inheritance in JavaScript
etc
var operation =
{
A: 1,
B: 2,
C: 3
};
var operationImplA =
{
D: 4
};
var operationImplB =
{
D: function (event) {
//do something
}
};
Something similar to the above but not sure how to do this in JavaScript.
You can simply use
Object.create:Object.createwill create new object with prototype it’s first argument and properties defined in the second argument.This is the natural prototype-based inheritance in JavaScript.
Edit
If you want to add a method, add it like a property i.e.: