Hi,
 
Generally it's helpful if, when discussing a book, you also provide the edition
number and the page number you're looking at. I'm guessing that it's the second
edition and page 180.
 
That being said, there are problems with the series of these diagrams, so
unfortunately they're not terribly accurate. You're correct in that there's an
error in this diagram. The box for SubType Prototype should not have a
constructor property.
 
-N
 
 
 



On June 9, 2011 at 7:12 PM amit ahlawat <[email protected]> wrote:

> Hello everyone
>
> I have a small doubt related to the inheritance chapter provided in
> the book mentioned in the subject.
>
> The chapter explains combination inheritance, wherein a diagram is
> given to explain the following code:
>
> function SuperType(name){
> this.name = name;
> this.colors = [“red”, “blue”, “green”];
> }
>
> SuperType.prototype.sayName = function(){
> alert(this.name);
> };
>
> function SubType(name, age){
> SuperType.call(this, name); //second call to SuperType()
> this.age = age;
> }
>
> SubType.prototype = new SuperType(); //first call to SuperType()
>
> };
>
> The diagram shows that when SubType.prototype = new SuperType();  is
> executed, a new instance of SuperType is assigned as the prototype of
> the SubType object. In the end, the instance contains properties :
> ___proto__ , name and colors.
>
> But in addition, that instance is also shown to have a constructor
> property.
>
> It is mentioned in the same chapter that when SubType.prototype = new
> SuperType(); is executed, the constructor gets overwritten, so in this
> case there should be just an object having 3 properties ( __proto__,
> name and colors ) instead of 4.
>
> Can someone please clarify this issue.
>
> Thank you.
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to