I have an object that inherits from another object, like so:
var a = function ()
{
}
a.prototype.foo = function ()
{
bar();
}
var b = function ()
{
a.call(this)
}
b.prototype = Object.create(a.prototype);
b.prototype.constructor = b;
I want to have a method of b that is also named "foo" and extends a's function with the same name.
b.prototype.foo = function ()
{
baz();
// When .foo() is called, runs both bar() and baz()
}
Is there a simple way to accomplish this in native JavaScript without the aid of libraries?