|
From: Theo B. <be...@ot...> - 2001-01-20 21:27:08
|
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...
-----------------------------------
|