Mapping multiple keys to the same value in a Javascript hash
- by Bears will eat you
I use a Javascript hash object to store a set of numerical counters, set up like this [this is greatly simplified]:
var myHash = {
A: 0,
B: 0,
C: 0
};
Is there a way to make other keys, ones not explicitly in myHash, map to keys that are? For instance, I'd like [again, this is simplified]:
myHash['A_prime']++; // or myHash.A_prime++;
to be exactly equivalent to
myHash['A']++; // or myHash.A++;
e.g. incrementing the value found at the key A, not A_prime.