English 中文(简体)
希望使用 j式阵列作为散射钥匙,取回任何阵列元素
原标题:wishing to use a javascript array as a hash key, retrieve with any array element

Here s what I m looking to do..

var dual = new Array; 
dual=[voter,thisID];
var matrix = new Array;
matrix[dual]=voteint; //this works..

但是,我愿意轻易地通过两个关键(信息)要素获取价值观:

matrix[*,thisID])=answer; 

除野生卡外,没有这种方式?

one could do...

matrix[voter+ . +thisID]=voteint;

reg reg matching

最佳回答
> var dual = new Array; 
> dual=[voter,thisID];

第二项任务取代原先分配给dual的阵列,使第一个派任无用。 可以写成:

var dual = [voter, thisID];

只有在以下情况下,才宣布或设定为先前变量:voter和dual

> var matrix = new Array;
> matrix[dual]=voteint; //this works..

如上所述,第1项任务是多余的。

“工程”是指将财产分配到matrix,即dual.toString(<>/code>,这样,如果你写:

var voter =  foo ;
var thisID =  baz ;
var dual = [foo, baz];

之后

matrix[dual] = voteint;

相当于:

matrix[ foo,baz ] = voteing;

voteint 以前被分配价值。

but I d like to easily access values by either or both key (array) element:

> matrix[*,thisID])=answer;

except wildcards don t exist in this way, right?

不是在这种情况下,第2号。

......

矩阵表 +thisID=voteint;

如果. 改为“ com”,是。

and do regex matching around the . but is there a better/easier/faster way?

如果表示反对,则使用阿雷拉是一种不良做法,因此最好在此使用目的。

您的唯一合理选择是利用,在上,对每个财产名称进行测试,以找到你想要的物。 请注意,你还应包括“清白”测试,以排除继承的无数财产。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.