Bonjour
Il y a quelque chose que je ne comprends pas avec les tableaux associatifs :
Le code suivant :
devrait m'afficher, selon toutes vraissemblance :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 <html> <head> <title>Document sans titre</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/JavaScript"> Array.prototype.popAll=function() { while (this.length>0) { this.pop(); } } Array.prototype.test=function() { return this; } var s=""; var t1=new Array(); t1[0]=new Array(); t1[0]["test2"]="Roro"; for (var e in t1[0]){ s += ("-" + t1[0][e] + "<br/>") } function test() { document.getElementById("s").innerHTML=s; } </script> </head> <body> <div id="s"></div> <button type="button" onClick="test()">wazy</button> </body> </html>
Mais il n'en est rien !- Roro
Il m'affiche :1 / Je ne comprends pas pourquoi-Roro
-function () { while (this.length > 0) { this.pop(); } }
-function () { return this; }
2 / Comment faire en sorte qu'il n'affiche que ce que j'espérais, à savoir : "-Roro" ?
(J'ai dit "bizarre" ? étrange ...!)
Partager