I am currently trying to understand the JS prototype chain mechanism.
I have tried the following:
TestObject = function(){
this.sayHello();
this.sayGoodbye();
};
TestObject.prototype = {
sayHello:function(){
alert("Hi thereee");
}
};
TestObject.prototype.prototype = {
sayGoodbye:function(){
alert("See yaaaaa");
}
};
When I add
<script>var test = new TestObject();</script>
to my index.php, the following happens:
First, a window pops up, saying "Hi thereee", which is what I'd expect to happen. But then, the console tells me that the application crashed because 'sayGoodbye' is not a member of the test object.
So, my questtion is: what is happening here and how can I make actual prototype chains that are longer than just one single step?
Thanks a lot to everyone in advance.