So im trying to create a relatively simple dictionary see snippet below:
var res = {"id":$( "#chose_partner option:selected" ).val(),
"name":$( "#chose_partner option:selected" ).text()};
var_current_partner_id = $("#chose_partner option:selected").val();
try{
//if dictionary already has the "trip_stop" key then append value to its value as its a list
var_user_record.trip_info['trip_stops'].push('res');
console.log('found stops so adding %o ', var_user_record);
}catch (e){
//if "trips_stop" doesn't exist then declare it as a list and append my value
console.log('error looking for specific trip %o %o %o ',var_user_record['trip_info'],var_user_record.trip_info,var_user_record);
var_user_record['trip_info']['trip_stops'] = [];
var_user_record['trip_info']['trip_stops'].push(res);
}
The logic if dictionary already has the "trip_stop" key then append value to its value as its a list.
if "trips_stop" doesn't exist then declare it as a list and append my value.
The output is so unexpected see below
They are two things happening here
- THe logging is logging a value that is declared in the next line ? How is that possible unless console.log can be delyed on chrome?
- The third object is the main dictionary but doesn't show the recently added keys even though refrencing it through var_user_record['trip_info'],var_user_record.trip_info yields values but not var_user_record doesn't show it