Let us say I have an object Airport with members airportCode and airportCity like this:
function Airport(airportCode, airportCity) {
this.airportCode = airportCode;
this.airportCity = airportCity;
};
How can I create an array of objects Airport to which I can add. In Java, this would work like this:
while(st.hasMoreTokens()) {
Airport a = new Airport();
a.airportCode = st.nextToken();
a.airportCity = st.nextToken();
airports.add(a);
}
var airports = [];
. Then, in the loop, create anAirport
instance, and add it to the array using theairports.push
method. – Rob W Jul 17 '12 at 21:12st
in your javascript code? – Bergi Jul 17 '12 at 21:15