In populate()populate()
function of service.jsservice.js, I was trying to build an object array to store the passengers' namename
, househouse
, placemarkplacemark
and markermarker
. Basically, I created a global array, say database[]database[]
, then when iterating through every passenger's information in PASSENGERS[]PASSENGERS[]
,I add both the property and value dynamically:
database[i].name = PASSENGERS[i].name;
database[i].house = PASSENGERS[i].house;
database[i].placemark = placemark;
database[i].marker = marker;
When I validate the code using 'Inspect Elements' on Google, it pops out the message: Uncaught TypeError:Cannot set property 'name' of undefined.
Uncaught TypeError:Cannot set property 'name' of undefined.
Is that the correct way to declare an object array? Or is there anything wrong with adding new property and values? Much appreciated.