简体   繁体   中英

Objects within an Array, to be referenced later

I want to place all the hmAttKeys under one type of hmFeeTypeAttKey so that when I later reference hmAttKeys, it comes out individually but I am not sure of the right sytax. I also tried hmFeeTypeAttKey[0] = [13,3,11,12] . Any suggestions?

hmAttKeys=[]
hmAttKeys[13]="/red";
hmAttKeys[3]="/blue";
hmAttKeys[11]="/green";
hmAttKeys[12]="/yellow";

var hmFeeTypeAttKey = [];
hmFeeTypeAttKey[0] = [13][3][11][12]; 

hmAttKeys[hmFeeTypeIndex[0]] 
hmAttKeys=[]
hmAttKeys[13]="/red";
hmAttKeys[3]="/blue";
hmAttKeys[11]="/green";
hmAttKeys[12]="/yellow";    
i=0;
var hmFeeTypeAttKey = [];
for( key in hmAttKeys )
{
hmFeeTypeAttKey[i]=key;
i++;
}

now you can loop through the array to get the keys back for reference..

for(var j=0;j<hmfeeTypeAttKey.length;j++)
{
console.log(hmAttKeys[hmfeeTypeAttKey[j]])
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM