From: Robert R. <rra...@ya...> - 2001-01-20 22:02:07
|
I totally agree. I tried doing that with the dynapi, and it crashed and burned. Especially when trying mulitiple inheritance. Even though the constructor is always called an extra time, it makes the inheritance chain work. -- // Robert Rainwater On 1/20/2001, 4:56:21 PM EST, Pascal wrote about "[Dynapi-Widgetdev] aggregating prototypes": > 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 >> > _______________________________________________ > Dynapi-Widgetdev mailing list > Dyn...@li... > http://lists.sourceforge.net/lists/listinfo/dynapi-widgetdev |