I have this code:
function Stickman() {
//some methods and properties
}
function JuniorStickman() {
Stickman.call(this);
this.p = new value // override a property in Stickman
}
JuniorStickman.prototype = new Stickman();
junior = new JuniorStickman();
I adapted this code from an example at MDN: https://developer.mozilla.org/en-US/docs/JavaScript/Introduction_to_Object-Oriented_JavaScript
What I don't understand is this: call() and the line
JuniorStickman.prototype = new Stickman()
seem to do the same thing. If I comment out the line
JuniorStickman.prototype = new Stickman();
my JuniorStickman still has all the methods and properties of Stickman; True; his prototype property is now JuniorStickman and not Stickman but it doesn't seem to matter.
How does call work here to make my Junior Stickman (junior) have all the methods of Stickman and is the prototype assignment necessary?
As I understand it call() is not really giving me inheritance. I am just getting a sort of copy of Stickman to which I can add / override properties. Is this correct?