> var dual = new Array;
> dual=[voter,thisID];
The second assignment replaces the array originally assigned to dual, making the first assignment useless. It can be written:
var dual = [voter, thisID];
but only if voter and dual have been declared or created as variables earlier.
> var matrix = new Array;
> matrix[dual]=voteint; //this works..
As above, the first assignment to matrix is redundant.
It "works" by assigning a property to matrix that is dual.toString(), so if you'd written:
var voter = 'foo';
var thisID = 'baz';
var dual = [foo, baz];
then
matrix[dual] = voteint;
is equivalent to:
matrix['foo,baz'] = voteing;
if voteint has been assigned a value earlier.
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?
Not in that context, no.
one could do...
matrix[voter+'.'+thisID]=voteint;
If the . was replaced by a comma, yes.
and
do regex matching around the '.' but
is there a better/easier/faster way?
It is considered bad practice to use an Array where an Object is indicated, so better to use an Object here.
Your only reasonable option is to iterate over the object's properties using for..in to test each property name to find the one you want. Note that you should also include a hasOwnProperty test to exclude inherited enumerable properties.