Connecting Tech Pros Worldwide Help | Site Map

Tableau associatif

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 02:30 PM
Guy Roydor
Guest
 
Posts: n/a
Default Tableau associatif

est-il possible de traiter un tableau de façon "associative" (comme ds PHP ?

Merci;
G.Roydor

exemple : tab ["macle"]


  #2  
Old July 20th, 2005, 02:30 PM
Cenekemoi
Guest
 
Posts: n/a
Default Re: Tableau associatif

Bonjour à Guy Roydor <guy.roydor@nospamlaposte.net> qui nous a écrit :[color=blue]
> est-il possible de traiter un tableau de façon "associative" (comme
> ds PHP ?
>
> Merci;
> G.Roydor
>
> exemple : tab ["macle"][/color]

Oui, par exemple :

tab = new Array();

tab[ "cle1" ] = "valeur1";
tab[ "cle2" ] = "valeur2";
tab[ "cle3" ] = "valeur3";

for( var i = 1; i < 4; i++) {
alert( tab[ "cle"+ i ] );
}

tab[ "cle4" ] = new Array();

tab[ "cle4" ][ "cle4-1" ] = "valeur4-1";
tab[ "cle4" ][ "cle4-2" ] = "valeur4-2";
tab[ "cle4" ][ "cle4-3" ] = "valeur4-3";

etc...

Rq: on ne peut pas, en Javascript, créé des tableaux à double entrée,
ie:

tab[ "cle4", "cle4-1" ] = "valeur4-1"; //==> est invalide

--
Cordialement, Thierry ;-)

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.