Don P: was bewirkt {}

Beitrag lesen

Hallo,

ist aber gleichzeitig JS Form eines assoziativen Arrays!

Es gibt keine assoziativen Arrays in JavaScript, nur normale Arrays oder eben Objekte. Was du "assoziatives Array" nennst ist ein normales Objekt mit Eigenschaften/Methoden. Der Unterschied ist, dass echte Arrays eine Eigenschaft namens length haben, das ist die Anzahl der Arrayeinträge. Ein "assoziatives Array" bzw. ein normales Objekt hat keine Eigenschaft length, und falls doch, sie gibt nicht die Anzahl der Eigenschaften/Methoden zurück.

var array = [];
array.prop1 = 1;
array.prop2 = 2;
alert(array.length); // 0

Gruß, Don P

0 139

was bewirkt {}

Ric
  • javascript
  1. 0
    Don P
  2. 0
    KurtZ
    1. 0
      Don P
      1. 0
        KurtZ
        1. 0
          Don P
          1. 0
            KurtZ
            1. 0
              Don P
              1. 0
                KurtZ
                1. 0
                  Cheatah
                  1. 0
                    KurtZ
                    1. 0
                      Don P
                      1. 0
                        KurtZ
                        1. 0
                          Siechfred
                    2. 0
                      Cheatah
        2. 0
          Don P
          1. 0
            KurtZ
            1. 0
              Don P
              1. 0
                KurtZ
    2. 0
      Cheatah
      1. 0
        KurtZ
        1. 0
          Siechfred
          1. 0
            KurtZ
            1. 0
              Cheatah
              1. 0
                KurtZ
                1. 1
                  Siechfred
                  1. 0
                    KurtZ
                    1. 0
                      Siechfred
                      1. 0
                        KurtZ
                        1. 0
                          Don P
                      2. 0
                        Siechfred
                      3. 2
                        Daniel Thoma
                        1. 0
                          KurtZ
                        2. 0
                          Siechfred
                          1. 0
                            Daniel Thoma
                            1. 0
                              Struppi
      2. 0

        "Herrje" Cheatah

        KurtZ
        1. 0
          Don P
          1. 0
            KurtZ
            1. 1
              Don P
              1. 0
                KurtZ
                1. 0
                  Don P
                  1. 0
                    KurtZ
        2. 0
          Siechfred
          1. 0
            KurtZ
            1. 0
              KurtZ
              1. 0
                Christoph
                1. 0
                  KurtZ
                  1. 0
                    Christoph
                    1. 0
                      LanX
                      1. 0
                        LanX
                        1. 0
                          Don P
                          1. 0
                            KurtZ
                            1. 0
                              Don P
                      2. 0
                        molily
                        1. 0
                          Christoph
                          1. 0
                            KurtZ
                            1. 0
                              Struppi
                            2. 0
                              Struppi
                            3. 0
                              Christoph
                              1. 0
                                Don P
                              2. 0
                                molily
                                1. 0
                                  molily
                              3. 0

                                "Herrje" Christoph

                                KurtZ
                                1. 0
                                  KurtZ
                                  1. 0
                                    Christoph
                                    1. 0
                                      KurtZ
                                      1. 0
                                        molily
                          2. 0
                            LanX²
                        2. 0
                          LanX²
                          1. 0
                            molily
                            1. 0
                              LanX²
                              1. 0
                                molily
                                1. 0
                                  KurtZ
                                  1. 0
                                    molily
                                    1. 0
                                      KurtZ
                              2. 0
                                KurtZ
                                1. 0
                                  LanX²
                    2. 0
                      molily
                      1. 0
                        LanX
                        1. 0
                          molily
                      2. 0
                        Christoph
            2. 0
              Siechfred
              1. 1

                Lieber SIechfred!

                KurtZ
                1. 0
                  Struppi
                  1. 0
                    Don P
                  2. 0
                    KurtZ
                    1. 0
                      Struppi
                      1. 0
                        KurtZ
                        1. 0
                          Struppi
                          1. 0

                            Lieber Struppi!

                            KurtZ
                          2. 1
                            Christoph
                            1. 0
                              Struppi
                            2. 0

                              Lieber Christof ;)

                              KurtZ
                              1. 0
                                KurtZ
                              2. 1
                                Christoph
                              3. 0

                                Lieber Christo__ph__ ;)

                                Christoph
                                1. 0
                                  KurtZ
                2. 0
                  Siechfred
                  1. 0

                    Lieber Siechfred!

                    KurtZ
                    1. 0
                      molily
                      1. 0
                        KurtZ
                3. 0
                  KurtZ
          2. 0

            Der Hash in Prototype

            Tim Tepaße
        3. 0
          Cheatah
          1. 0
            KurtZ
            1. 0
              Cheatah
      3. 0

        Übrigens, JS hat auch keine Arrays!

        KurtZ
        1. 0
          Don P
        2. 0
          Struppi
          1. 0
            KurtZ
            1. 0
              Struppi
              1. 0
                KurtZ
                1. 0
                  KurtZ
                2. 0
                  Struppi
                  1. 0
                    KurtZ
                    1. 0
                      Struppi
                      1. 0
                        KurtZ
                        1. 0
                          molily
                    2. 1
                      Don P
                      1. 0
                        KurtZ
                      2. 0
                        molily
                  2. 1
                    molily
        3. 2
          molily
        4. 0
          Harlequin
    3. 3
      KurtZ
    4. 0
      Struppi
      1. 0
        KurtZ
        1. 0
          molily
          1. 0
            KurtZ
            1. 0
              Christoph
              1. 0
                KurtZ
                1. 0
                  KurtZ
  3. 0

    Assoziative Arrays - es gibt sie doch!

    Christoph
    1. 0

      leicht modifiziert

      Christoph
      1. 0

        Iteratoren zur Realisierung von »reinen« Hashes nutzen

        Tim Tepaße
        1. 0
          Christoph
          1. 0
            Tim Tepaße
    2. 0
      Struppi