From: Pascal B. <pa...@dy...> - 2001-01-20 21:56:58
|
now try some more interesting constructions with multiple instances of a certain widget and of making another object with is based on widget B. Trust me on this one (please) that this is the way to do correct prototyping in Javascript. There are netscape documents on the net that verify this :-) cya, Pascal Bestebroer pa...@dy... http://www.dynamic-core.net > -----Oorspronkelijk bericht----- > Van: dyn...@li... > [mailto:dyn...@li...]Namens Theo Bebekis > Verzonden: zaterdag 20 januari 2001 22:46 > Aan: dyn...@li... > Onderwerp: [Dynapi-Widgetdev] aggregating prototypes > > > Hi > > Is there any difference between the two? > > 1st case > --------------------------------- > function A() { } > function B() { } > B.prototype = new A() > > 2nd case > --------------------------------- > function A() { } > function B() { } > B.prototype = A.prototype > > > > I'm getting the same result in either case. > Please, try the following code by changing > the prototype assignment > > <script language="Javascript" > > function A() { } > A.prototype.say = function() {alert("a say")} > > function B() { } > B.prototype = A.prototype > B.prototype.A_say = A.prototype.say > B.prototype.say = function() > alert("b say") > this.A_say() > } > > function C() { } > C.prototype = B.prototype > C.prototype.B_say = B.prototype.say > C.prototype.say = function() > alert("c say") > this.B_say() > } > > var c = new C() > c.say() > </script> > > > > Theo > > ----------------------------------- > Theo Bebekis > Thessaloniki, Greece > be...@ot... > ----------------------------------- > > _______________________________________________ > Dynapi-Widgetdev mailing list > Dyn...@li... > http://lists.sourceforge.net/lists/listinfo/dynapi-widgetdev > |