prototypal inheritance: the prototype object
- From: Jessica <JessAlba13@xxxxxxxxxxxxxx>
- Date: Fri, 30 Nov 2007 06:44:03 -0800 (PST)
Hi,
I have a question referring prototypal inheritance in javascript.
My example:
function A() {};
A.prototype = {
count: 10,
doit : function () {alert ("doit");}
};
function B() {};
B.prototype = new A;
B.prototype.constructor = B;
The line "B.prototype = new A()" creates an object in the memory for
example at the adress "x1".
The B-definition references this object in its prototype-property.
Then I create an instance of B. I try to get the value of "count":
var test = new B();
var tmp = test.count;
Is it still the object at the adress "x1" that gives me the values of
the property, or does every instance have an own prototype-object (a
copy?) that contains the value?
Thank you very much in advance.
Greetings Jess
.
- Follow-Ups:
- Re: prototypal inheritance: the prototype object
- From: Thomas 'PointedEars' Lahn
- Re: prototypal inheritance: the prototype object
- From: VK
- Re: prototypal inheritance: the prototype object
- Prev by Date: Refer to <div> from separate <frame>
- Next by Date: Re: Refer to <div> from separate <frame>
- Previous by thread: Refer to <div> from separate <frame>
- Next by thread: Re: prototypal inheritance: the prototype object
- Index(es):