mozilla

Compare Revisions

Inheritance revisited

Change Revisions

Revision 56927:

Revision 56927 by user01 on

Revision 56928:

Revision 56928 by ericbock on

Title:
Inheritance revisited
Inheritance revisited
Slug:
JavaScript/Guide/Inheritance_Revisited
JavaScript/Guide/Inheritance_Revisited
Tags:
JavaScript, OOP, Inheritance
JavaScript, OOP, Inheritance
Content:

Revision 56927
Revision 56928
t64      For example, when you do <code>var a1 = new A(); var a2 = nt64      If, in the example aboveyou do <code>var a1 = new A(); va
>ew A();</code> in the example above, then <code>a1.doSomething</c>r a2 = new A();</code> then <code>a1.doSomething</code> would act
>ode> would actually refer to <code>a1.__proto__.doSomething</code>ually refer to <code>a1.__proto__.doSomething</code>, which is th
>>, which is the same as <code>A.prototype.doSomething</code> you >e same as the <code>A.prototype.doSomething</code> you defined, i
>defined, i.e. <code>a1.__proto__.doSomething == a2.__proto__.doSo>.e. <code>a1.__proto__.doSomething == a2.__proto__.doSomething ==
>mething == A.prototype.doSomething</code>.> A.prototype.doSomething</code>.

Back to History