I have found this code...
var newEntry, table = [];
newEntry = {
id: '321',
price: '1000',
};
table.push(newEntry);
alert(table[0].id);
It works like expected. However I need to add more than one entry, like this...
var newFont, newColor, table = [];
newFont = {
family: 'arial',
size: '12',
};
newColor = {
hex: 'red',
};
table.push(newFont);
table.push(newColor);
alert(table[0].font);
Problem
- I don't want to write
table[0].family. - Instead I would like to write
table['font'].family. - It's a named key instead of just a number. It would be better if the settings increase.