Struppi: Vererbungshierarchie ?!?

Beitrag lesen

wie funktioniert eigentlich das prototype-Attribut genau?

Im Prinzip wie alle anderen Attribute, nur das in dem Moment wo du new Konstruktor() machst, die Instanz die Eigenschaften des Prototype bekommt.

vertausche ich aber die prototype-Anweisungen

instance.prototype = new class1();
class1.prototype = new class0();


>   
> bekomme ich nur:  
> function class1() { this.class1 = "SUB"; }  
> instance: EXEMPLAR  
> class1: SUB  
  
Wenn du den prototypen von instance deklarierst, ist class1 noch kein prototype von class0(), das passiert erst danach.  
  

>   
> Wieso ist die Reihenfolge relevant??? Prototyp wird doch dynamisch ausgewertet...  
  
genau.  
  

> und wieso ändert sich der constructor???  
  
Weil der Konstruktor zum Zeitpunkt der prototype Zuweisung class1() ist.  
  

> Kann mir jemand bitte einen guten Link geben wo Vererbungsketten und prototype genau erklärt werden?  
  
Was Vererbung in JS angeht ist [Douglas Crockford](http://crockford.com/javascript/inheritance.html) empfehlenswert.  
  
Struppi.
0 67

Vererbungshierarchie ?!?

Kurt Z
  • javascript
  1. 0
    Struppi
    1. 0
      molily
    2. 0
      Don P
      1. 0
        Kurt Z
        1. 0
          Struppi
          1. 0
            Don P
            1. 0
              Struppi
              1. 0
                Don P
                1. 0
                  Struppi
                  1. 0
                    Don P
                    1. 0
                      Struppi
                      1. 0
                        Don P
                        1. 0
                          Struppi
                          1. 0
                            Don P
                      2. 0
                        Kurt Z
                        1. 0
                          Struppi
                          1. 0
                            Kurt Z
                            1. 0
                              Struppi
                              1. 0
                                Kurt Z
                                1. 0
                                  Struppi
                                  1. 0
                                    Kurt Z
                                    1. 0
                                      LanX²
                                    2. 0
                                      Struppi
                                      1. 0
                                        Kurt Z
                                        1. 0
                                          Kurt Z
                                        2. 0
                                          Struppi
                                          1. 0
                                            Kurt Z
                              2. 0
                                Don P
              2. 0
                LanX²
                1. 0

                  Function.prototype.begetObject

                  LanX²
                  1. 0
                    Don P
                    1. 0

                      Knobelaufgabe

                      LanX²
                      1. 0
                        Don P
                    2. 0
                      molily
                      1. 0
                        Kurt Z
                        1. 0

                          Please beget it!

                          LanX²
                          1. 0
                            Kurt Z
                          2. 0
                            Don P
                            1. 0
                              LanX²
                              1. 0
                                Don P
                              2. 0

                                Iterator

                                KurtZ
                                1. 0
                                  LanX
                      2. 0
                        Don P
        2. 0

          new Object(x) statt object(x)

          Kurt Z
          1. 0
            Murphy
            1. 0
              Kurt Z
              1. 0
                Don P
              2. 0
                Murphy
                1. 0
                  Kurt Z
                2. 0
                  molily
  2. 0
    LanX²
  3. 0
    molily
  4. 3

    __proto__ chain

    LanX²
    1. 0
      LanX²
      1. 0
        Kurt Z
    2. 1
      molily
  5. 0

    JS-Version?

    Kurt Z
    1. 0
      Kurt Z
      1. 0
        molily
        1. 0
          molily
    2. 0
      molily
      1. 0
        Kurt Z
        1. 0
          molily
          1. 0
            Kurt Z
  6. 0

    VIELEN DANK!!!

    Kurt Z
    1. 0
      Struppi