Imagine the following scenario:
I have two classes: Parent and Child. Parent has a method foo(). Child wants to override foo(), and within do whatever foo() did in Parent's foo().
In any other programming language i would just do something like
foo(){
super.foo();
//do new stuff
}
But in javascript there's no such thing. Here's a short version of my code:
function Parent( name, stuff ){
this.name = name;
this.stuff = stuff;
}
Parent.prototype = {
foo: function(){
console.log('foo');
}
}
function Child(name, stuff, otherStuff ){
Parent.call(this, name, stuff);
this.otherStuff = otherStuff;
}
Child.prototype = new Parent();
Child.prototype.foo = function(){
???//I want to call my parents foo()! :(
console.log('bar');
}
What I want to achieve is that when an instance of Child calls foo() i can get foobar in the console.
Thanks!
PS: please, no JQuery, PrototypeJS, ExtJs, etc... This is a Javascript project and also a learning exercise. Thank you.