I'm trying to store data into a javascript variable.
Here is my scenario : I have a list of people (person_id, person_name), and each person is succeptible to have pets (pet_id, pet_name) and/or toys (toys_id).
[Persons]
Person_Id
Person_Name
[Pets]
Pet_Id
Pet_Name
[Toys]
Toy_Id
I tried various things and even if sometimes I can get everything stored I'm unsure i'm doing it the right way.
Should i store the IDs as keys ? Is like this correctly done ? Knowing later i will try to know how many pets and toys each person have. Also, my variable is supposed to store 1 or many persons.
var myVar = {person_id:{
person_name:'',
pet_id:{
pet_name:''
},
toys:{
toys_id:''
}
}};
Some help would be much appreciated.