So from the title itself. I have an initialize object like say
"travellerDetails": {
"traveller_1": {
"Full Name": "",
"Gender": "",
}, "traveller_2": {
"Full Name": "",
"Gender": "",
}, "traveller_3": {
"Full Name": "",
"Gender": ""
}
}
However, when I load my data object from an Ajax call
"travellerDetails": {
"traveller_1": {
"Full Name": "John Doe",
"Gender": "M",
}, "traveller_2": {
"Full Name": "Jane Doe",
"Gender": "F",
}
},
I get an error when I try to store the loaded data to an initialize object.
bookingForm.travellerDetails = data.travellerDetails;
I was expecting that traveller_3 will be set as "" considering that I only have 2 travellers when loaded. But when the initialize object is the same size as the one I loaded from an ajax call my code runs perfectly. So how do I copy the loaded object to the initialize one with different sizes?
Thanks!