I have an array consisting of A LOT of Symbol
objects:
var symbols = {
alpha : new Symbol('alpha', 'symbol_0', 'α', 'GreekSymbol'),
beta : new Symbol('beta', 'symbol_1', 'β', 'GreekSymbol'),
gamma : new Symbol('gamma', 'symbol_2', 'γ', 'GreekSymbol'),
delta : new Symbol('delta', 'symbol_3', 'δ', 'GreekSymbol'),
... about 500 of these different types of symbols...
};
The second parameter for the Symbol
object is an ID that will be used in HTML. Since the HTML specs don't allow duplicate IDs, I want to assign each Symbol
a unique ID and still be able to know that this ID corresponds to a Symbol
. So I like the idea of having the symbol_
prefix but I don't like the idea of manually typing out symbol_0
through symbol_500
.
How should I generate unique IDs? Can I automate this process and generate a unique ID when I'm declaring the above array?
UPDATE
Is it actually a good idea to do this client-side?