Combinazione di strutture dati in JS
Le due tipologie possono essere combinate fra loro:
array di oggetti
dati = [
{ chiaveA: 123, chiaveB: 234 },
{ chiaveA: 345, chiaveB: 456 }
];
valore = dati[0].chiaveB; // valore == 234
oggetto con array
dati = {
chiaveA: [ 123, 234 ],
chiaveB: [ 345, 456 ]
};
valore = dati.chiaveB[0]; // valore == 345