loop sur tableau associatif
Bonjour,
Je boucle sur un tableau associatif afin d'en afficher le contenu, mais j'ai un petit problème.
Voici la déclaration du tableau :
Code:
1 2 3 4 5
| var boutons_array = new Array();
boutons_array["60"] = "b_60";
boutons_array["80"] = "b_80";
boutons_array["100"] = "b_100";
boutons_array["120"] = "b_120"; |
Ensuite je boucle sur celui-ci:
Code:
1 2 3 4 5
| for (var i in boutons_array) {
document.write("The index is:<em> "+ i );
document.write(".</em> The value is: <em>" + boutons_array[i]
+ ".</em><br>");
} |
Et j'obtiens ceci:
Code:
1 2 3 4 5 6 7 8 9
|
The index is: 60. The value is: b_60.
The index is: 80. The value is: b_80.
The index is: 100. The value is: b_100.
The index is: 120. The value is: b_120.
The index is: indexOf. The value is: function (s) { for (var a = 0; a < this.length; a++) { if (this[a] == s) { return a; } } return -1; } .
The index is: deleteItem. The value is: function (i) { if (i < 0 || i > (this.length - 1)) { return; } if (i == (this.length - 1)) { this.length--; return; } for (var a = (i + 1); a < this.length; a++) { this[a - 1] = this[a]; } this.length--; } .
The index is: deleteValue. The value is: function (v) { for (var a = 0; a < this.length; a++) { if (this[a] == v) { this.deleteItem(a); } } } .
The index is: insert. The value is: function (i, v) { if (i < 0 || i > (this.length - 1)) { return; } for (var a = this.length; a > i; a--) { this[a] = this[a - 1]; } this[i] = v; } . |
d'où viennent ces éléments?