View Single Post
  #4 (permalink)  
Old 09-26-2003, 06:00 AM
RJS RJS is offline
Member
 
Join Date: Sep 2003
Posts: 56
Default Re:associativ array ?

Below some further explorations: This approach seems to work and provides a useful basis for some data structures.

var objArray = new Object();
objArray[1] = 1;
objArray[2] = 2;
objArray[3] = 3;
objArray['index1'] = 'string_1';
objArray.index2 = 'string_2';


trace (objArray[1]);
trace (objArray['index1']);
trace (objArray.index2);

objArray.index3 = objArray[3];
for (var ndx in objArray) {
trace(ndx + ':' + objArray[ndx]);
}

Trace:

1
string_1
string_2
__proto__:3
index3:3
index2:string_2
index1:string_1
Reply With Quote