简体   繁体   English

数组中的对象,稍后将引用

[英]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. 我想将所有hmAttKeys放在一种hmFeeTypeAttKey类型下,以便以后我引用hmAttKeys时,它会单独出现,但是我不确定正确的语法。 I also tried hmFeeTypeAttKey[0] = [13,3,11,12] . 我还尝试了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]])
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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